PVData C++ 8.0.7
Loading...
Searching...
No Matches
templateMeta.h
1/*
2 * Copyright information and license terms for this software can be
3 * found in the file LICENSE that is included with the distribution
4 */
7#ifndef TEMPLATEMETA_H
8#define TEMPLATEMETA_H
9
10// gently nudge the compiler to inline our wrappers
11// Warning: Only use this when the template body is *small*.
12// You have been warned!
13#if defined(__MINGW32__)
14# define FORCE_INLINE inline
15#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 402)
16# define FORCE_INLINE __attribute__((always_inline)) inline
17#elif defined(_MSC_VER)
18# define FORCE_INLINE __forceinline
19#else
20# define FORCE_INLINE inline
21#endif
22
23namespace epics { namespace pvData {
24namespace meta {
25
34template<typename T> struct decorate_const { typedef const T type; };
35template<typename T> struct decorate_const<const T> { typedef const T type; };
36
43template<typename T> struct strip_const { typedef T type; };
44template<typename T> struct strip_const<const T> { typedef T type; };
45
63template<typename A, typename B, typename R = void>
64struct not_same_type {typedef R type;};
65template<typename A>
66struct not_same_type<A,A> {};
67
69template<typename A, typename B, class R = void> struct same_root {};
70template<typename T, class R> struct same_root<T,T,R> { typedef R type; };
71template<typename T, class R> struct same_root<const T,T,R> { typedef R type; };
72template<typename T, class R> struct same_root<T,const T,R> { typedef R type; };
73
74namespace detail {
75 struct _const_yes {};
76 struct _const_no {};
77 template<typename T> struct _has_const { typedef _const_no type; };
78 template<typename T> struct _has_const<const T> { typedef _const_yes type; };
79
80 template<typename A, typename B, class R = void> struct _same_type {};
81 template<typename T, class R> struct _same_type<T,T,R> { typedef R type; };
82} // namespace detail
83
85template<typename A, typename B, class R = void>
86struct same_const :
87 public detail::_same_type<typename detail::_has_const<A>::type,
88 typename detail::_has_const<B>::type,
89 R>
90{};
91
104template<typename T, class R = void> struct is_void {};
105template<class R> struct is_void<void,R> { typedef R type; };
106template<class R> struct is_void<const void,R> { typedef R type; };
107
109template<typename T, class R = void> struct is_not_void { typedef R type; };
110template<> struct is_not_void<void> {};
111template<> struct is_not_void<const void> {};
112
114template<typename A, typename B, class EnableA = void, class EnableB = void, class R = void>
115struct _and {};
116template<typename A, typename B, class R>
117struct _and<A,B, typename A::type, typename B::type, R> { typedef R type; };
118
124template<typename T>
125struct arg_type {typedef const T& type;};
126#define SIMPLE_ARG_TYPE(TYPE) template<> struct arg_type<TYPE> { typedef TYPE type; };
127SIMPLE_ARG_TYPE(bool)
128SIMPLE_ARG_TYPE(char)
129SIMPLE_ARG_TYPE(signed char)
130SIMPLE_ARG_TYPE(unsigned char)
131SIMPLE_ARG_TYPE(short)
132SIMPLE_ARG_TYPE(unsigned short)
133SIMPLE_ARG_TYPE(int)
134SIMPLE_ARG_TYPE(unsigned int)
135SIMPLE_ARG_TYPE(long)
136SIMPLE_ARG_TYPE(unsigned long)
137SIMPLE_ARG_TYPE(long long)
138SIMPLE_ARG_TYPE(unsigned long long)
139SIMPLE_ARG_TYPE(float)
140SIMPLE_ARG_TYPE(double)
141SIMPLE_ARG_TYPE(long double)
142#undef SIMPLE_ARG_TYPE
143
144}}}
145
146#endif // TEMPLATEMETA_H
epics
Definition convert.h:21
Enabler to ensure that both conditions A and B are true.
Check if both A and B are either const or non-const.
Select if both A and B have the same root type (excluding const qualifier)