-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype_traits.cpp
146 lines (126 loc) · 2.49 KB
/
type_traits.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include <eggs/type_patterns.hpp>
using namespace eggs::type_patterns;
/** 20.9.4.1 primary type categories **/
// checks if a type is void
template< typename T >
struct is_void
: match<
T
, ignore_cv< void >
>
{};
// checks if a type is integral type
template< typename T >
struct is_integral
: match<
T
, ignore_cv< ignore_sign< any_of< bool, char, char16_t, char32_t, wchar_t, short, int, long, long long > > >
>
{};
// checks if a type is floating-point type
template< typename T >
struct is_floating_point
: match<
T
, ignore_cv< any_of< float, double, long double > >
>
{};
// checks if a type is an array type
template< typename T >
struct is_array
: match<
T
, any_of< _[], _[N] >
>
{};
// checks if a type is a function type
template< typename T >
struct is_function
: match<
T
, _( varargs )
>
{};
// checks if a type is a pointer type
template< typename T >
struct is_pointer
: match<
T
, ignore_cv< _* >
>
{};
// checks if a type is lvalue reference
template< typename T >
struct is_lvalue_reference
: match<
T
, _&
>
{};
// checks if a type is rvalue reference
template< typename T >
struct is_rvalue_reference
: match<
T
, _&&
>
{};
// checks if a type is a pointer to a non-static member object
template< typename T >
struct is_member_object_pointer
: match<
T
, not_< ignore_cv< _( varargs ) > > _::*
>
{};
// checks if a type is a pointer to a non-static member function
template< typename T >
struct is_member_function_pointer
: match<
T
, ignore_cv< _( varargs ) > _::*
>
{};
/** 20.9.4.2, composite type categories **/
// checks if a type is either lvalue reference or rvalue reference
template< typename T >
struct is_reference
: match<
T
, any_of< _&, _&& >
>
{};
// checks if a type is a pointer to a non-static member function or object
template< typename T >
struct is_member_pointer
: match<
T
, _ _::*
>
{};
/** 20.9.4.3, type properties **/
// checks if a type is const-qualified
template< typename T >
struct is_const
: match<
T
, _ const
>
{};
// checks if a type is volatile-qualified
template< typename T >
struct is_volatile
: match<
T
, _ volatile
>
{};
/** 20.9.6, type relations **/
// checks if two types are the same
template< typename T, typename U >
struct is_same
: match<
T
, U
>
{};