]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/tr1/type_traits
name-lookup.c (leave_scope): We only need to update class_binding_level when leaving...
[thirdparty/gcc.git] / libstdc++-v3 / include / tr1 / type_traits
CommitLineData
493bc460
PC
1// TR1 type_traits -*- C++ -*-
2
3// Copyright (C) 2004 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 2, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License along
17// with this library; see the file COPYING. If not, write to the Free
18// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19// USA.
20
21/** @file
22 * This is a TR1 C++ Library header.
23 */
24
e21cb773
PC
25#ifndef _TYPE_TRAITS
26#define _TYPE_TRAITS 1
493bc460
PC
27
28#include <bits/c++config.h>
29#include <cstddef>
30
31//namespace std::tr1
32namespace std
33{
34namespace tr1
35{
36 /// @brief helper classes [4.3].
37 template<typename _Tp, _Tp __v>
38 struct integral_constant
39 {
40 static const _Tp value = __v;
41 typedef _Tp value_type;
42 typedef integral_constant<_Tp, __v> type;
43 };
44 typedef integral_constant<bool, true> true_type;
45 typedef integral_constant<bool, false> false_type;
46
47#define _DEFINE_PRIMARY_SPEC_HELPER(_Primary, _Type) \
48 template<> \
49 struct _Primary<_Type> \
50 : public true_type { };
51
52#define _DEFINE_PRIMARY_SPEC(_Primary, _Type) \
53 _DEFINE_PRIMARY_SPEC_HELPER(_Primary, _Type) \
54 _DEFINE_PRIMARY_SPEC_HELPER(_Primary, _Type const) \
55 _DEFINE_PRIMARY_SPEC_HELPER(_Primary, _Type volatile) \
56 _DEFINE_PRIMARY_SPEC_HELPER(_Primary, _Type const volatile)
57
58 /// @brief primary type categories [4.5.1].
59 template<typename>
60 struct is_void
61 : public false_type { };
62 _DEFINE_PRIMARY_SPEC(is_void, void)
63
64 template<typename>
65 struct is_integral
66 : public false_type { };
67 _DEFINE_PRIMARY_SPEC(is_integral, bool)
68 _DEFINE_PRIMARY_SPEC(is_integral, char)
69 _DEFINE_PRIMARY_SPEC(is_integral, signed char)
70 _DEFINE_PRIMARY_SPEC(is_integral, unsigned char)
71#ifdef _GLIBCXX_USE_WCHAR_T
72 _DEFINE_PRIMARY_SPEC(is_integral, wchar_t)
73#endif
74 _DEFINE_PRIMARY_SPEC(is_integral, short)
75 _DEFINE_PRIMARY_SPEC(is_integral, unsigned short)
76 _DEFINE_PRIMARY_SPEC(is_integral, int)
77 _DEFINE_PRIMARY_SPEC(is_integral, unsigned int)
78 _DEFINE_PRIMARY_SPEC(is_integral, long)
79 _DEFINE_PRIMARY_SPEC(is_integral, unsigned long)
80 _DEFINE_PRIMARY_SPEC(is_integral, long long)
81 _DEFINE_PRIMARY_SPEC(is_integral, unsigned long long)
82
83 template<typename>
84 struct is_floating_point
85 : public false_type { };
86 _DEFINE_PRIMARY_SPEC(is_floating_point, float)
87 _DEFINE_PRIMARY_SPEC(is_floating_point, double)
88 _DEFINE_PRIMARY_SPEC(is_floating_point, long double)
89
90 template<typename>
91 struct is_array
92 : public false_type { };
93
94 template<typename _Tp, std::size_t _Size>
95 struct is_array<_Tp[_Size]>
96 : public true_type { };
97
98 template<typename _Tp>
99 struct is_array<_Tp[]>
100 : public true_type { };
101
102 template<typename _Tp>
103 struct is_pointer;
104
e21cb773
PC
105 template<typename>
106 struct is_reference
107 : public false_type { };
108
493bc460 109 template<typename _Tp>
e21cb773
PC
110 struct is_reference<_Tp&>
111 : public true_type { };
493bc460
PC
112
113 template<typename _Tp>
114 struct is_member_object_pointer;
115
116 template<typename _Tp>
117 struct is_member_function_pointer;
118
119 template<typename _Tp>
120 struct is_enum;
121
122 template<typename _Tp>
123 struct is_union;
124
125 template<typename _Tp>
126 struct is_class;
127
128 template<typename _Tp>
129 struct is_function;
130
131#undef _DEFINE_PRIMARY_SPEC_HELPER
132#undef _DEFINE_PRIMARY_SPEC
133
134 /// @brief composite type traits [4.5.2].
135 template<typename _Tp>
136 struct is_arithmetic
137 : public integral_constant<bool, (is_integral<_Tp>::value
138 || is_floating_point<_Tp>::value)>
139 { };
140
141 template<typename _Tp>
142 struct is_fundamental
143 : public integral_constant<bool, (is_arithmetic<_Tp>::value
144 || is_void<_Tp>::value)>
145 { };
146
147 template<typename _Tp>
148 struct is_object
149 : public integral_constant<bool, !(is_function<_Tp>::value
150 || is_reference<_Tp>::value
151 || is_void<_Tp>::value)>
152 { };
153
154 template<typename _Tp>
155 struct is_member_pointer
156 : public integral_constant<bool,
157 (is_member_object_pointer<_Tp>::value
158 || is_member_function_pointer<_Tp>::value)>
159 { };
160
161 template<typename _Tp>
162 struct is_scalar
163 : public integral_constant<bool, (is_arithmetic<_Tp>::value
164 || is_enum<_Tp>::value
165 || is_pointer<_Tp>::value
166 || is_member_pointer<_Tp>::value)>
167 { };
168
169 template<typename _Tp>
170 struct is_compound
171 : public integral_constant<bool, !is_fundamental<_Tp>::value> { };
172
173 /// @brief type properties [4.5.3].
174 template<typename _Tp>
175 struct is_const;
176
177 template<typename _Tp>
178 struct is_volatile;
179
180 template<typename _Tp>
181 struct is_pod;
182
183 template<typename _Tp>
184 struct is_empty;
185
186 template<typename _Tp>
187 struct is_polymorphic;
188
189 template<typename _Tp>
190 struct is_abstract;
191
192 template<typename _Tp>
193 struct has_trivial_constructor;
194
195 template<typename _Tp>
196 struct has_trivial_copy;
197
198 template<typename _Tp>
199 struct has_trivial_assign;
200
201 template<typename _Tp>
202 struct has_trivial_destructor;
203
204 template<typename _Tp>
205 struct has_nothrow_constructor;
206
207 template<typename _Tp>
208 struct has_nothrow_copy;
209
210 template<typename _Tp>
211 struct has_nothrow_assign;
212
213 template<typename _Tp>
214 struct has_virtual_destructor
215 : public false_type { };
216
217 template<typename _Tp>
218 struct is_signed;
219
220 template<typename _Tp>
221 struct is_unsigned;
222
223 template<typename _Tp>
224 struct alignment_of;
225
226 template<typename _Tp>
227 struct rank;
228
229 template<typename _Tp, unsigned _Uint = 0>
230 struct extent;
231
232 /// @brief relationships between types [4.6].
233 template<typename _Tp, typename _Up>
234 struct is_same;
235
236 template<typename _From, typename _To>
237 struct is_convertible;
238
239 template<typename _Base, typename _Derived>
240 struct is_base_of;
241
242 /// @brief const-volatile modifications [4.7.1].
243 template<typename _Tp>
244 struct remove_const;
245
246 template<typename _Tp>
247 struct remove_volatile;
248
249 template<typename _Tp>
250 struct remove_cv;
251
252 template<typename _Tp>
253 struct add_const;
254
255 template<typename _Tp>
256 struct add_volatile;
257
258 template<typename _Tp>
259 struct add_cv;
260
261 /// @brief reference modifications [4.7.2].
262 template<typename _Tp>
263 struct remove_reference;
264
265 template<typename _Tp>
266 struct add_reference;
267
268 /// @brief array modififications [4.7.3].
269 template<typename _Tp>
270 struct remove_extent;
271
272 template<typename _Tp>
273 struct remove_all_extents;
274
275 /// @brief pointer modifications [4.7.4].
276 template<typename _Tp>
277 struct remove_pointer;
278
279 template<typename _Tp>
280 struct add_pointer;
281
282 /// @brief other transformations [4.8].
283 template<std::size_t _Len, std::size_t _Align>
284 struct aligned_storage;
285}
286}
287
288#endif