STIR  6.3.0
type_traits.h
Go to the documentation of this file.
1 
2 /*
3  Copyright (C) 2025, University College London
4  This file is part of STIR.
5 
6  SPDX-License-Identifier: Apache-2.0
7 
8  See STIR/LICENSE.txt for details
9 */
10 
11 #ifndef __stir_typetraits_H__
12 #define __stir_typetraits_H__
13 
22 #include <type_traits>
23 #include "stir/common.h"
24 
25 START_NAMESPACE_STIR
26 
44 
45 #if 0
46 // Helper template to check if a method exists
47 template <typename T>
48 struct has_method_foo<T, typename = void> : std::false_type {};
49 struct has_method_foo<T, std::void_t<decltype(std::declval<T>().foo())>> : std::true_type {}; // Specialization: method exists
50 
51 #endif
52 
54 template <typename T, typename = void>
55 struct has_iterator : std::false_type
56 {
57 };
58 
59 template <typename T>
60 struct has_iterator<T, std::void_t<typename T::iterator>> : std::true_type
61 {
62 };
63 
65 template <typename T>
67 
69 template <typename T, typename = void>
70 struct has_full_iterator : std::false_type
71 {
72 };
73 
74 template <typename T>
75 struct has_full_iterator<T, std::void_t<typename T::full_iterator>> : std::true_type
76 {
77 };
78 
80 template <typename T>
82 
84 template <typename T>
85 struct has_iterator_and_no_full_iterator : std::conjunction<has_iterator<T>, std::negation<has_full_iterator<T>>>
86 {
87 };
88 
90 template <typename T>
92 
94 
95 END_NAMESPACE_STIR
96 
97 #endif
STL namespace.
Helper to check if a type has a full_iterator typedef (e.g. Array<2,int>)
Definition: type_traits.h:70
constexpr bool has_iterator_and_no_full_iterator_v
Bool set to has_iterator_and_no_full_iterator<T>::value.
Definition: type_traits.h:91
Helper to check if the type has an iterator but no full_iterator typedef (e.g. std::vector<int>) ...
Definition: type_traits.h:85
constexpr bool has_full_iterator_v
Bool set to has_full_iterator<T>::value.
Definition: type_traits.h:81
basic configuration include file
constexpr bool has_iterator_v
Bool set to has_iterator<T>::value.
Definition: type_traits.h:66
Helper to check if a type has an iterator typedef.
Definition: type_traits.h:55