STIR 6.4.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
25START_NAMESPACE_STIR
26
44
45#if 0
46// Helper template to check if a method exists
47template <typename T>
48struct has_method_foo<T, typename = void> : std::false_type {};
49struct has_method_foo<T, std::void_t<decltype(std::declval<T>().foo())>> : std::true_type {}; // Specialization: method exists
50
51#endif
52
54template <typename T, typename = void>
55struct has_iterator : std::false_type
56{
57};
58
59template <typename T>
60struct has_iterator<T, std::void_t<typename T::iterator>> : std::true_type
61{
62};
63
65template <typename T>
67
69template <typename T, typename = void>
70struct has_full_iterator : std::false_type
71{
72};
73
74template <typename T>
75struct has_full_iterator<T, std::void_t<typename T::full_iterator>> : std::true_type
76{
77};
78
80template <typename T>
82
84template <typename T>
85struct has_iterator_and_no_full_iterator : std::conjunction<has_iterator<T>, std::negation<has_full_iterator<T>>>
86{
87};
88
90template <typename T>
92
94
95END_NAMESPACE_STIR
96
97#endif
basic configuration include file
constexpr bool has_full_iterator_v
Bool set to has_full_iterator<T>::value.
Definition type_traits.h:81
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
constexpr bool has_iterator_v
Bool set to has_iterator<T>::value.
Definition type_traits.h:66
Helper to check if a type has a full_iterator typedef (e.g. Array<2,int>)
Definition type_traits.h:71
Helper to check if the type has an iterator but no full_iterator typedef (e.g. std::vector<int>)
Definition type_traits.h:86
Helper to check if a type has an iterator typedef.
Definition type_traits.h:56