cppexpose  1.0.0.b785e04f23b8
C++ library for type introspection, reflection, and scripting interface
template_helpers.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 
5 #include <array>
6 #include <type_traits>
7 
8 #include <cppexpose/cppexpose_api.h>
9 
10 
11 namespace cppexpose
12 {
13 
14 
19 namespace helper
20 {
21 
22 
23 template <bool Condition, bool... MoreConditions>
24 struct CPPEXPOSE_TEMPLATE_API all;
25 
26 template <bool... MoreConditions>
27 struct CPPEXPOSE_TEMPLATE_API all<true, MoreConditions...> : public all<MoreConditions...> {};
28 
29 template <bool... MoreConditions>
30 struct CPPEXPOSE_TEMPLATE_API all<false, MoreConditions...> : public std::false_type {};
31 
32 template <>
33 struct CPPEXPOSE_TEMPLATE_API all<true> : public std::true_type {};
34 
35 template <bool Condition>
36 struct CPPEXPOSE_TEMPLATE_API neg : public std::true_type {};
37 
38 template <>
39 struct CPPEXPOSE_TEMPLATE_API neg<true> : public std::false_type {};
40 
41 template <typename Type>
42 struct CPPEXPOSE_TEMPLATE_API is_array : public std::false_type {};
43 
44 template <typename Type, size_t Size>
45 struct CPPEXPOSE_TEMPLATE_API is_array<std::array<Type, Size>> : public std::true_type {};
46 
47 template <typename Type, typename Container>
48 struct CPPEXPOSE_TEMPLATE_API is_special_array : public std::false_type {};
49 
50 template <typename Type, size_t Size>
51 struct CPPEXPOSE_TEMPLATE_API is_special_array<Type, std::array<Type, Size>> : public std::true_type {};
52 
53 template <typename Condition, typename Type>
54 struct CPPEXPOSE_TEMPLATE_API value_accessor : public std::enable_if<Condition::value, Type> {};
55 
62 template <typename Condition, typename Type = void>
64 
65 template <typename Condition>
66 struct CPPEXPOSE_TEMPLATE_API Neg : public neg<Condition::value> {};
67 
68 template <bool... Conditions>
69 struct CPPEXPOSE_TEMPLATE_API And : public all<Conditions...> {};
70 
71 template <typename Type>
72 struct CPPEXPOSE_TEMPLATE_API isArray : public is_array<Type> {};
73 
74 template <typename Type>
75 struct CPPEXPOSE_TEMPLATE_API isBoolArray : public is_special_array<bool, Type> {};
76 
77 template <typename Type>
78 struct CPPEXPOSE_TEMPLATE_API isIntArray : public is_special_array<int, Type> {};
79 
80 template <typename Type>
81 struct CPPEXPOSE_TEMPLATE_API isDoubleArray : public is_special_array<double, Type> {};
82 
83 template <typename Type>
84 struct CPPEXPOSE_TEMPLATE_API isIntegral : public And<std::is_integral<Type>::value,
85  Neg<std::is_same<Type, bool>>::value> {};
86 
87 template <typename Type>
88 struct CPPEXPOSE_TEMPLATE_API isUnsignedIntegral : public And<std::is_integral<Type>::value,
89  std::is_unsigned<Type>::value,
90  Neg<std::is_same<Type, bool>>::value> {};
91 
92 template <typename Type>
93 struct CPPEXPOSE_TEMPLATE_API isSignedIntegral : public And<std::is_integral<Type>::value,
94  std::is_signed<Type>::value,
95  Neg<std::is_same<Type, bool>>::value> {};
96 
97 template <typename Type>
98 struct CPPEXPOSE_TEMPLATE_API isFloatingPoint : public And<std::is_floating_point<Type>::value,
99  Neg<std::is_same<Type, long double>>::value> {};
100 
101 template <typename Type>
102 struct CPPEXPOSE_TEMPLATE_API isPlain : public And<Neg<std::is_reference<Type>>::value,
103  Neg<std::is_const<Type>>::value,
104  Neg<std::is_volatile<Type>>::value> {};
105 
106 
107 } // namespace helper
108 
109 
110 } // namespace cppexpose
Definition: template_helpers.h:75
Definition: template_helpers.h:98
Definition: template_helpers.h:78
Definition: function_helpers.h:12
Definition: template_helpers.h:84
Definition: template_helpers.h:88
Definition: template_helpers.h:93
Definition: template_helpers.h:42
Definition: template_helpers.h:66
Definition: template_helpers.h:72
Definition: template_helpers.h:102
Definition: template_helpers.h:36
struct CPPEXPOSE_TEMPLATE_API all
Definition: template_helpers.h:24
Definition: template_helpers.h:69
Definition: template_helpers.h:54
typename value_accessor< Condition, Type >::type EnableIf
Used to choose specific property implementation for different types at compile time via SFINAE...
Definition: template_helpers.h:63
Definition: template_helpers.h:81
Definition: template_helpers.h:48