]>
Commit | Line | Data |
---|---|---|
c0ffa2ba | 1 | // C++11 <type_traits> -*- C++ -*- |
af13a7a6 | 2 | |
85ec4feb | 3 | // Copyright (C) 2007-2018 Free Software Foundation, Inc. |
af13a7a6 BK |
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 | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
af13a7a6 BK |
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 | ||
748086b7 JJ |
16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version | |
18 | // 3.1, as published by the Free Software Foundation. | |
19 | ||
20 | // You should have received a copy of the GNU General Public License and | |
21 | // a copy of the GCC Runtime Library Exception along with this program; | |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | // <http://www.gnu.org/licenses/>. | |
af13a7a6 BK |
24 | |
25 | /** @file include/type_traits | |
26 | * This is a Standard C++ Library header. | |
27 | */ | |
28 | ||
4514bed6 BK |
29 | #ifndef _GLIBCXX_TYPE_TRAITS |
30 | #define _GLIBCXX_TYPE_TRAITS 1 | |
af13a7a6 BK |
31 | |
32 | #pragma GCC system_header | |
33 | ||
734f5023 | 34 | #if __cplusplus < 201103L |
ab65a4c7 | 35 | # include <bits/c++0x_warning.h> |
57317d2a | 36 | #else |
af13a7a6 | 37 | |
8fc81078 | 38 | #include <bits/c++config.h> |
e133ace8 | 39 | |
21e2806a JW |
40 | namespace std _GLIBCXX_VISIBILITY(default) |
41 | { | |
42 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
43 | ||
8e32aa11 | 44 | /** |
c0ffa2ba | 45 | * @defgroup metaprogramming Metaprogramming |
13901e4b JW |
46 | * @ingroup utilities |
47 | * | |
48 | * Template utilities for compile-time introspection and modification, | |
49 | * including type classification traits, type property inspection traits | |
50 | * and type transformation traits. | |
51 | * | |
5b9daa7e BK |
52 | * @{ |
53 | */ | |
ac65b7d2 DK |
54 | |
55 | /// integral_constant | |
56 | template<typename _Tp, _Tp __v> | |
57 | struct integral_constant | |
58 | { | |
59 | static constexpr _Tp value = __v; | |
60 | typedef _Tp value_type; | |
61 | typedef integral_constant<_Tp, __v> type; | |
352111c5 | 62 | constexpr operator value_type() const noexcept { return value; } |
db113eda | 63 | #if __cplusplus > 201103L |
a15f7cb8 ESR |
64 | |
65 | #define __cpp_lib_integral_constant_callable 201304 | |
66 | ||
352111c5 | 67 | constexpr value_type operator()() const noexcept { return value; } |
db113eda | 68 | #endif |
ac65b7d2 | 69 | }; |
33ac58d5 | 70 | |
c0ffa2ba BK |
71 | template<typename _Tp, _Tp __v> |
72 | constexpr _Tp integral_constant<_Tp, __v>::value; | |
73 | ||
13901e4b | 74 | /// The type used as a compile-time boolean with true value. |
ac65b7d2 DK |
75 | typedef integral_constant<bool, true> true_type; |
76 | ||
13901e4b | 77 | /// The type used as a compile-time boolean with false value. |
ac65b7d2 DK |
78 | typedef integral_constant<bool, false> false_type; |
79 | ||
f6b640be JW |
80 | template<bool __v> |
81 | using __bool_constant = integral_constant<bool, __v>; | |
82 | ||
46ba1281 | 83 | #if __cplusplus > 201402L |
f9badf71 | 84 | # define __cpp_lib_bool_constant 201505 |
46ba1281 JW |
85 | template<bool __v> |
86 | using bool_constant = integral_constant<bool, __v>; | |
87 | #endif | |
88 | ||
123c516a | 89 | // Meta programming helper types. |
53dc5044 | 90 | |
123c516a PC |
91 | template<bool, typename, typename> |
92 | struct conditional; | |
53dc5044 | 93 | |
dd7b175e | 94 | template<typename...> |
123c516a PC |
95 | struct __or_; |
96 | ||
ac65b7d2 DK |
97 | template<> |
98 | struct __or_<> | |
99 | : public false_type | |
100 | { }; | |
101 | ||
dd7b175e PC |
102 | template<typename _B1> |
103 | struct __or_<_B1> | |
104 | : public _B1 | |
105 | { }; | |
106 | ||
123c516a PC |
107 | template<typename _B1, typename _B2> |
108 | struct __or_<_B1, _B2> | |
109 | : public conditional<_B1::value, _B1, _B2>::type | |
110 | { }; | |
111 | ||
112 | template<typename _B1, typename _B2, typename _B3, typename... _Bn> | |
113 | struct __or_<_B1, _B2, _B3, _Bn...> | |
114 | : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type | |
115 | { }; | |
53dc5044 | 116 | |
dd7b175e | 117 | template<typename...> |
123c516a | 118 | struct __and_; |
53dc5044 | 119 | |
ac65b7d2 DK |
120 | template<> |
121 | struct __and_<> | |
122 | : public true_type | |
123 | { }; | |
124 | ||
dd7b175e PC |
125 | template<typename _B1> |
126 | struct __and_<_B1> | |
127 | : public _B1 | |
128 | { }; | |
129 | ||
123c516a PC |
130 | template<typename _B1, typename _B2> |
131 | struct __and_<_B1, _B2> | |
132 | : public conditional<_B1::value, _B2, _B1>::type | |
133 | { }; | |
134 | ||
135 | template<typename _B1, typename _B2, typename _B3, typename... _Bn> | |
136 | struct __and_<_B1, _B2, _B3, _Bn...> | |
137 | : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type | |
138 | { }; | |
139 | ||
140 | template<typename _Pp> | |
141 | struct __not_ | |
4b9840f2 | 142 | : public __bool_constant<!bool(_Pp::value)> |
123c516a PC |
143 | { }; |
144 | ||
4b9840f2 | 145 | #if __cplusplus >= 201703L |
c3a6648b | 146 | |
068c8ac1 | 147 | #define __cpp_lib_logical_traits 201510 |
c3a6648b VV |
148 | |
149 | template<typename... _Bn> | |
150 | struct conjunction | |
151 | : __and_<_Bn...> | |
152 | { }; | |
153 | ||
154 | template<typename... _Bn> | |
155 | struct disjunction | |
156 | : __or_<_Bn...> | |
157 | { }; | |
158 | ||
159 | template<typename _Pp> | |
160 | struct negation | |
161 | : __not_<_Pp> | |
162 | { }; | |
137422c8 VV |
163 | |
164 | template<typename... _Bn> | |
4b9840f2 | 165 | inline constexpr bool conjunction_v = conjunction<_Bn...>::value; |
42183d03 | 166 | |
137422c8 | 167 | template<typename... _Bn> |
4b9840f2 | 168 | inline constexpr bool disjunction_v = disjunction<_Bn...>::value; |
42183d03 | 169 | |
137422c8 | 170 | template<typename _Pp> |
4b9840f2 | 171 | inline constexpr bool negation_v = negation<_Pp>::value; |
137422c8 | 172 | |
4b9840f2 | 173 | #endif // C++17 |
c3a6648b | 174 | |
b3618b71 DK |
175 | // For several sfinae-friendly trait implementations we transport both the |
176 | // result information (as the member type) and the failure information (no | |
177 | // member type). This is very similar to std::enable_if, but we cannot use | |
178 | // them, because we need to derive from them as an implementation detail. | |
179 | ||
180 | template<typename _Tp> | |
181 | struct __success_type | |
182 | { typedef _Tp type; }; | |
183 | ||
184 | struct __failure_type | |
185 | { }; | |
186 | ||
c0ffa2ba | 187 | // Primary type categories. |
123c516a | 188 | |
53dc5044 PC |
189 | template<typename> |
190 | struct remove_cv; | |
191 | ||
192 | template<typename> | |
193 | struct __is_void_helper | |
194 | : public false_type { }; | |
53dc5044 | 195 | |
123c516a PC |
196 | template<> |
197 | struct __is_void_helper<void> | |
198 | : public true_type { }; | |
53dc5044 PC |
199 | |
200 | /// is_void | |
201 | template<typename _Tp> | |
202 | struct is_void | |
82b12c4b | 203 | : public __is_void_helper<typename remove_cv<_Tp>::type>::type |
53dc5044 PC |
204 | { }; |
205 | ||
206 | template<typename> | |
207 | struct __is_integral_helper | |
208 | : public false_type { }; | |
123c516a PC |
209 | |
210 | template<> | |
211 | struct __is_integral_helper<bool> | |
212 | : public true_type { }; | |
33ac58d5 | 213 | |
123c516a PC |
214 | template<> |
215 | struct __is_integral_helper<char> | |
216 | : public true_type { }; | |
217 | ||
218 | template<> | |
219 | struct __is_integral_helper<signed char> | |
220 | : public true_type { }; | |
221 | ||
222 | template<> | |
223 | struct __is_integral_helper<unsigned char> | |
224 | : public true_type { }; | |
225 | ||
53dc5044 | 226 | #ifdef _GLIBCXX_USE_WCHAR_T |
123c516a PC |
227 | template<> |
228 | struct __is_integral_helper<wchar_t> | |
229 | : public true_type { }; | |
53dc5044 | 230 | #endif |
123c516a PC |
231 | |
232 | template<> | |
233 | struct __is_integral_helper<char16_t> | |
234 | : public true_type { }; | |
235 | ||
236 | template<> | |
237 | struct __is_integral_helper<char32_t> | |
238 | : public true_type { }; | |
239 | ||
240 | template<> | |
241 | struct __is_integral_helper<short> | |
242 | : public true_type { }; | |
243 | ||
244 | template<> | |
245 | struct __is_integral_helper<unsigned short> | |
246 | : public true_type { }; | |
247 | ||
248 | template<> | |
249 | struct __is_integral_helper<int> | |
250 | : public true_type { }; | |
251 | ||
252 | template<> | |
253 | struct __is_integral_helper<unsigned int> | |
254 | : public true_type { }; | |
255 | ||
256 | template<> | |
257 | struct __is_integral_helper<long> | |
258 | : public true_type { }; | |
259 | ||
260 | template<> | |
261 | struct __is_integral_helper<unsigned long> | |
262 | : public true_type { }; | |
263 | ||
264 | template<> | |
265 | struct __is_integral_helper<long long> | |
266 | : public true_type { }; | |
267 | ||
268 | template<> | |
269 | struct __is_integral_helper<unsigned long long> | |
270 | : public true_type { }; | |
53dc5044 | 271 | |
78a7c317 DD |
272 | // Conditionalizing on __STRICT_ANSI__ here will break any port that |
273 | // uses one of these types for size_t. | |
274 | #if defined(__GLIBCXX_TYPE_INT_N_0) | |
6d585f01 | 275 | template<> |
78a7c317 | 276 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0> |
6d585f01 PC |
277 | : public true_type { }; |
278 | ||
279 | template<> | |
78a7c317 DD |
280 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0> |
281 | : public true_type { }; | |
282 | #endif | |
283 | #if defined(__GLIBCXX_TYPE_INT_N_1) | |
284 | template<> | |
285 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1> | |
286 | : public true_type { }; | |
287 | ||
288 | template<> | |
289 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1> | |
290 | : public true_type { }; | |
291 | #endif | |
292 | #if defined(__GLIBCXX_TYPE_INT_N_2) | |
293 | template<> | |
294 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2> | |
295 | : public true_type { }; | |
296 | ||
297 | template<> | |
298 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2> | |
299 | : public true_type { }; | |
300 | #endif | |
301 | #if defined(__GLIBCXX_TYPE_INT_N_3) | |
302 | template<> | |
303 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3> | |
304 | : public true_type { }; | |
305 | ||
306 | template<> | |
307 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3> | |
6d585f01 PC |
308 | : public true_type { }; |
309 | #endif | |
310 | ||
53dc5044 PC |
311 | /// is_integral |
312 | template<typename _Tp> | |
313 | struct is_integral | |
82b12c4b | 314 | : public __is_integral_helper<typename remove_cv<_Tp>::type>::type |
53dc5044 PC |
315 | { }; |
316 | ||
317 | template<typename> | |
318 | struct __is_floating_point_helper | |
319 | : public false_type { }; | |
123c516a PC |
320 | |
321 | template<> | |
322 | struct __is_floating_point_helper<float> | |
323 | : public true_type { }; | |
324 | ||
325 | template<> | |
326 | struct __is_floating_point_helper<double> | |
327 | : public true_type { }; | |
328 | ||
329 | template<> | |
330 | struct __is_floating_point_helper<long double> | |
331 | : public true_type { }; | |
53dc5044 | 332 | |
6d585f01 PC |
333 | #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) |
334 | template<> | |
335 | struct __is_floating_point_helper<__float128> | |
336 | : public true_type { }; | |
337 | #endif | |
338 | ||
53dc5044 PC |
339 | /// is_floating_point |
340 | template<typename _Tp> | |
341 | struct is_floating_point | |
82b12c4b | 342 | : public __is_floating_point_helper<typename remove_cv<_Tp>::type>::type |
53dc5044 PC |
343 | { }; |
344 | ||
345 | /// is_array | |
346 | template<typename> | |
347 | struct is_array | |
348 | : public false_type { }; | |
349 | ||
350 | template<typename _Tp, std::size_t _Size> | |
351 | struct is_array<_Tp[_Size]> | |
352 | : public true_type { }; | |
353 | ||
354 | template<typename _Tp> | |
355 | struct is_array<_Tp[]> | |
356 | : public true_type { }; | |
357 | ||
358 | template<typename> | |
359 | struct __is_pointer_helper | |
360 | : public false_type { }; | |
123c516a PC |
361 | |
362 | template<typename _Tp> | |
363 | struct __is_pointer_helper<_Tp*> | |
364 | : public true_type { }; | |
53dc5044 PC |
365 | |
366 | /// is_pointer | |
367 | template<typename _Tp> | |
368 | struct is_pointer | |
82b12c4b | 369 | : public __is_pointer_helper<typename remove_cv<_Tp>::type>::type |
53dc5044 PC |
370 | { }; |
371 | ||
123c516a PC |
372 | /// is_lvalue_reference |
373 | template<typename> | |
374 | struct is_lvalue_reference | |
375 | : public false_type { }; | |
376 | ||
53dc5044 | 377 | template<typename _Tp> |
123c516a PC |
378 | struct is_lvalue_reference<_Tp&> |
379 | : public true_type { }; | |
380 | ||
381 | /// is_rvalue_reference | |
382 | template<typename> | |
383 | struct is_rvalue_reference | |
384 | : public false_type { }; | |
53dc5044 | 385 | |
53dc5044 | 386 | template<typename _Tp> |
123c516a PC |
387 | struct is_rvalue_reference<_Tp&&> |
388 | : public true_type { }; | |
389 | ||
390 | template<typename> | |
53dc5044 PC |
391 | struct is_function; |
392 | ||
393 | template<typename> | |
394 | struct __is_member_object_pointer_helper | |
395 | : public false_type { }; | |
123c516a PC |
396 | |
397 | template<typename _Tp, typename _Cp> | |
398 | struct __is_member_object_pointer_helper<_Tp _Cp::*> | |
399 | : public integral_constant<bool, !is_function<_Tp>::value> { }; | |
53dc5044 PC |
400 | |
401 | /// is_member_object_pointer | |
402 | template<typename _Tp> | |
403 | struct is_member_object_pointer | |
82b12c4b FD |
404 | : public __is_member_object_pointer_helper< |
405 | typename remove_cv<_Tp>::type>::type | |
53dc5044 PC |
406 | { }; |
407 | ||
408 | template<typename> | |
409 | struct __is_member_function_pointer_helper | |
410 | : public false_type { }; | |
123c516a PC |
411 | |
412 | template<typename _Tp, typename _Cp> | |
413 | struct __is_member_function_pointer_helper<_Tp _Cp::*> | |
414 | : public integral_constant<bool, is_function<_Tp>::value> { }; | |
53dc5044 PC |
415 | |
416 | /// is_member_function_pointer | |
417 | template<typename _Tp> | |
418 | struct is_member_function_pointer | |
82b12c4b FD |
419 | : public __is_member_function_pointer_helper< |
420 | typename remove_cv<_Tp>::type>::type | |
53dc5044 PC |
421 | { }; |
422 | ||
423 | /// is_enum | |
424 | template<typename _Tp> | |
425 | struct is_enum | |
426 | : public integral_constant<bool, __is_enum(_Tp)> | |
427 | { }; | |
428 | ||
429 | /// is_union | |
430 | template<typename _Tp> | |
431 | struct is_union | |
432 | : public integral_constant<bool, __is_union(_Tp)> | |
433 | { }; | |
434 | ||
435 | /// is_class | |
436 | template<typename _Tp> | |
437 | struct is_class | |
438 | : public integral_constant<bool, __is_class(_Tp)> | |
439 | { }; | |
440 | ||
441 | /// is_function | |
442 | template<typename> | |
443 | struct is_function | |
444 | : public false_type { }; | |
123c516a | 445 | |
51dc6603 JM |
446 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
447 | struct is_function<_Res(_ArgTypes...) _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 | 448 | : public true_type { }; |
123c516a | 449 | |
51dc6603 JM |
450 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
451 | struct is_function<_Res(_ArgTypes...) & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
452 | : public true_type { }; |
453 | ||
51dc6603 JM |
454 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
455 | struct is_function<_Res(_ArgTypes...) && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
456 | : public true_type { }; |
457 | ||
51dc6603 JM |
458 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
459 | struct is_function<_Res(_ArgTypes......) _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 | 460 | : public true_type { }; |
123c516a | 461 | |
51dc6603 JM |
462 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
463 | struct is_function<_Res(_ArgTypes......) & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
464 | : public true_type { }; |
465 | ||
51dc6603 JM |
466 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
467 | struct is_function<_Res(_ArgTypes......) && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
468 | : public true_type { }; |
469 | ||
51dc6603 JM |
470 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
471 | struct is_function<_Res(_ArgTypes...) const _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 | 472 | : public true_type { }; |
123c516a | 473 | |
51dc6603 JM |
474 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
475 | struct is_function<_Res(_ArgTypes...) const & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
476 | : public true_type { }; |
477 | ||
51dc6603 JM |
478 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
479 | struct is_function<_Res(_ArgTypes...) const && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
480 | : public true_type { }; |
481 | ||
51dc6603 JM |
482 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
483 | struct is_function<_Res(_ArgTypes......) const _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 | 484 | : public true_type { }; |
123c516a | 485 | |
51dc6603 JM |
486 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
487 | struct is_function<_Res(_ArgTypes......) const & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
488 | : public true_type { }; |
489 | ||
51dc6603 JM |
490 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
491 | struct is_function<_Res(_ArgTypes......) const && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
492 | : public true_type { }; |
493 | ||
51dc6603 JM |
494 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
495 | struct is_function<_Res(_ArgTypes...) volatile _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 | 496 | : public true_type { }; |
123c516a | 497 | |
51dc6603 JM |
498 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
499 | struct is_function<_Res(_ArgTypes...) volatile & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
500 | : public true_type { }; |
501 | ||
51dc6603 JM |
502 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
503 | struct is_function<_Res(_ArgTypes...) volatile && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
504 | : public true_type { }; |
505 | ||
51dc6603 JM |
506 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
507 | struct is_function<_Res(_ArgTypes......) volatile _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 | 508 | : public true_type { }; |
123c516a | 509 | |
51dc6603 JM |
510 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
511 | struct is_function<_Res(_ArgTypes......) volatile & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
512 | : public true_type { }; |
513 | ||
51dc6603 JM |
514 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
515 | struct is_function<_Res(_ArgTypes......) volatile && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
516 | : public true_type { }; |
517 | ||
51dc6603 JM |
518 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
519 | struct is_function<_Res(_ArgTypes...) const volatile _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 | 520 | : public true_type { }; |
123c516a | 521 | |
51dc6603 JM |
522 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
523 | struct is_function<_Res(_ArgTypes...) const volatile & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
524 | : public true_type { }; |
525 | ||
51dc6603 JM |
526 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
527 | struct is_function<_Res(_ArgTypes...) const volatile && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
528 | : public true_type { }; |
529 | ||
51dc6603 JM |
530 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
531 | struct is_function<_Res(_ArgTypes......) const volatile _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 PC |
532 | : public true_type { }; |
533 | ||
51dc6603 JM |
534 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
535 | struct is_function<_Res(_ArgTypes......) const volatile & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
536 | : public true_type { }; |
537 | ||
51dc6603 JM |
538 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
539 | struct is_function<_Res(_ArgTypes......) const volatile && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
540 | : public true_type { }; |
541 | ||
a15f7cb8 ESR |
542 | #define __cpp_lib_is_null_pointer 201309 |
543 | ||
1e673415 | 544 | template<typename> |
aa940ab5 | 545 | struct __is_null_pointer_helper |
1e673415 | 546 | : public false_type { }; |
123c516a PC |
547 | |
548 | template<> | |
aa940ab5 | 549 | struct __is_null_pointer_helper<std::nullptr_t> |
123c516a | 550 | : public true_type { }; |
1e673415 | 551 | |
aa940ab5 PC |
552 | /// is_null_pointer (LWG 2247). |
553 | template<typename _Tp> | |
554 | struct is_null_pointer | |
555 | : public __is_null_pointer_helper<typename remove_cv<_Tp>::type>::type | |
556 | { }; | |
557 | ||
558 | /// __is_nullptr_t (extension). | |
1e673415 PC |
559 | template<typename _Tp> |
560 | struct __is_nullptr_t | |
aa940ab5 | 561 | : public is_null_pointer<_Tp> |
1e673415 PC |
562 | { }; |
563 | ||
c0ffa2ba | 564 | // Composite type categories. |
123c516a PC |
565 | |
566 | /// is_reference | |
567 | template<typename _Tp> | |
568 | struct is_reference | |
569 | : public __or_<is_lvalue_reference<_Tp>, | |
570 | is_rvalue_reference<_Tp>>::type | |
571 | { }; | |
572 | ||
53dc5044 PC |
573 | /// is_arithmetic |
574 | template<typename _Tp> | |
575 | struct is_arithmetic | |
123c516a | 576 | : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type |
53dc5044 PC |
577 | { }; |
578 | ||
579 | /// is_fundamental | |
580 | template<typename _Tp> | |
581 | struct is_fundamental | |
aa940ab5 PC |
582 | : public __or_<is_arithmetic<_Tp>, is_void<_Tp>, |
583 | is_null_pointer<_Tp>>::type | |
53dc5044 PC |
584 | { }; |
585 | ||
586 | /// is_object | |
587 | template<typename _Tp> | |
588 | struct is_object | |
123c516a PC |
589 | : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>, |
590 | is_void<_Tp>>>::type | |
53dc5044 PC |
591 | { }; |
592 | ||
123c516a | 593 | template<typename> |
53dc5044 PC |
594 | struct is_member_pointer; |
595 | ||
596 | /// is_scalar | |
597 | template<typename _Tp> | |
598 | struct is_scalar | |
123c516a | 599 | : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>, |
aa940ab5 | 600 | is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type |
53dc5044 PC |
601 | { }; |
602 | ||
603 | /// is_compound | |
604 | template<typename _Tp> | |
605 | struct is_compound | |
606 | : public integral_constant<bool, !is_fundamental<_Tp>::value> { }; | |
607 | ||
53dc5044 PC |
608 | template<typename _Tp> |
609 | struct __is_member_pointer_helper | |
610 | : public false_type { }; | |
123c516a PC |
611 | |
612 | template<typename _Tp, typename _Cp> | |
613 | struct __is_member_pointer_helper<_Tp _Cp::*> | |
614 | : public true_type { }; | |
53dc5044 | 615 | |
13901e4b | 616 | /// is_member_pointer |
53dc5044 | 617 | template<typename _Tp> |
123c516a | 618 | struct is_member_pointer |
82b12c4b | 619 | : public __is_member_pointer_helper<typename remove_cv<_Tp>::type>::type |
53dc5044 PC |
620 | { }; |
621 | ||
89898034 DK |
622 | // Utility to detect referenceable types ([defns.referenceable]). |
623 | ||
624 | template<typename _Tp> | |
625 | struct __is_referenceable | |
626 | : public __or_<is_object<_Tp>, is_reference<_Tp>>::type | |
627 | { }; | |
628 | ||
c6ab9061 JW |
629 | template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM> |
630 | struct __is_referenceable<_Res(_Args...) _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
631 | : public true_type |
632 | { }; | |
633 | ||
c6ab9061 JW |
634 | template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM> |
635 | struct __is_referenceable<_Res(_Args......) _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
636 | : public true_type |
637 | { }; | |
638 | ||
c0ffa2ba | 639 | // Type properties. |
123c516a | 640 | |
53dc5044 PC |
641 | /// is_const |
642 | template<typename> | |
643 | struct is_const | |
644 | : public false_type { }; | |
645 | ||
646 | template<typename _Tp> | |
647 | struct is_const<_Tp const> | |
648 | : public true_type { }; | |
33ac58d5 | 649 | |
53dc5044 PC |
650 | /// is_volatile |
651 | template<typename> | |
652 | struct is_volatile | |
653 | : public false_type { }; | |
654 | ||
655 | template<typename _Tp> | |
656 | struct is_volatile<_Tp volatile> | |
657 | : public true_type { }; | |
658 | ||
123c516a PC |
659 | /// is_trivial |
660 | template<typename _Tp> | |
661 | struct is_trivial | |
662 | : public integral_constant<bool, __is_trivial(_Tp)> | |
663 | { }; | |
664 | ||
f5e523b7 VV |
665 | // is_trivially_copyable |
666 | template<typename _Tp> | |
667 | struct is_trivially_copyable | |
668 | : public integral_constant<bool, __is_trivially_copyable(_Tp)> | |
669 | { }; | |
123c516a PC |
670 | |
671 | /// is_standard_layout | |
672 | template<typename _Tp> | |
673 | struct is_standard_layout | |
674 | : public integral_constant<bool, __is_standard_layout(_Tp)> | |
675 | { }; | |
676 | ||
677 | /// is_pod | |
678 | // Could use is_standard_layout && is_trivial instead of the builtin. | |
679 | template<typename _Tp> | |
680 | struct is_pod | |
681 | : public integral_constant<bool, __is_pod(_Tp)> | |
682 | { }; | |
683 | ||
684 | /// is_literal_type | |
685 | template<typename _Tp> | |
686 | struct is_literal_type | |
687 | : public integral_constant<bool, __is_literal_type(_Tp)> | |
688 | { }; | |
689 | ||
53dc5044 PC |
690 | /// is_empty |
691 | template<typename _Tp> | |
692 | struct is_empty | |
693 | : public integral_constant<bool, __is_empty(_Tp)> | |
694 | { }; | |
695 | ||
696 | /// is_polymorphic | |
697 | template<typename _Tp> | |
698 | struct is_polymorphic | |
699 | : public integral_constant<bool, __is_polymorphic(_Tp)> | |
700 | { }; | |
701 | ||
4db7fcb9 ESR |
702 | #if __cplusplus >= 201402L |
703 | #define __cpp_lib_is_final 201402L | |
704 | /// is_final | |
705 | template<typename _Tp> | |
706 | struct is_final | |
707 | : public integral_constant<bool, __is_final(_Tp)> | |
708 | { }; | |
709 | #endif | |
710 | ||
53dc5044 PC |
711 | /// is_abstract |
712 | template<typename _Tp> | |
713 | struct is_abstract | |
714 | : public integral_constant<bool, __is_abstract(_Tp)> | |
715 | { }; | |
716 | ||
123c516a | 717 | template<typename _Tp, |
6a4b1a00 | 718 | bool = is_arithmetic<_Tp>::value> |
123c516a PC |
719 | struct __is_signed_helper |
720 | : public false_type { }; | |
721 | ||
53dc5044 | 722 | template<typename _Tp> |
6a4b1a00 PC |
723 | struct __is_signed_helper<_Tp, true> |
724 | : public integral_constant<bool, _Tp(-1) < _Tp(0)> | |
53dc5044 PC |
725 | { }; |
726 | ||
123c516a | 727 | /// is_signed |
53dc5044 | 728 | template<typename _Tp> |
123c516a | 729 | struct is_signed |
82b12c4b | 730 | : public __is_signed_helper<_Tp>::type |
123c516a PC |
731 | { }; |
732 | ||
733 | /// is_unsigned | |
734 | template<typename _Tp> | |
735 | struct is_unsigned | |
f7632193 | 736 | : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>> |
123c516a PC |
737 | { }; |
738 | ||
739 | ||
c0ffa2ba | 740 | // Destructible and constructible type properties. |
123c516a | 741 | |
13901e4b JW |
742 | /** |
743 | * @brief Utility to simplify expressions used in unevaluated operands | |
744 | * @ingroup utilities | |
745 | */ | |
ec26ff5a JW |
746 | |
747 | template<typename _Tp, typename _Up = _Tp&&> | |
748 | _Up | |
749 | __declval(int); | |
750 | ||
751 | template<typename _Tp> | |
752 | _Tp | |
753 | __declval(long); | |
754 | ||
53dc5044 | 755 | template<typename _Tp> |
ec26ff5a | 756 | auto declval() noexcept -> decltype(__declval<_Tp>(0)); |
53dc5044 | 757 | |
123c516a PC |
758 | template<typename, unsigned = 0> |
759 | struct extent; | |
760 | ||
761 | template<typename> | |
762 | struct remove_all_extents; | |
763 | ||
764 | template<typename _Tp> | |
765 | struct __is_array_known_bounds | |
766 | : public integral_constant<bool, (extent<_Tp>::value > 0)> | |
53dc5044 PC |
767 | { }; |
768 | ||
123c516a PC |
769 | template<typename _Tp> |
770 | struct __is_array_unknown_bounds | |
f7632193 | 771 | : public __and_<is_array<_Tp>, __not_<extent<_Tp>>> |
53dc5044 | 772 | { }; |
33ac58d5 | 773 | |
62fa805f | 774 | // In N3290 is_destructible does not say anything about function |
2c7a09d7 | 775 | // types and abstract types, see LWG 2049. This implementation |
62fa805f DK |
776 | // describes function types as non-destructible and all complete |
777 | // object types as destructible, iff the explicit destructor | |
2c7a09d7 | 778 | // call expression is wellformed. |
62fa805f | 779 | struct __do_is_destructible_impl |
123c516a | 780 | { |
62fa805f | 781 | template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())> |
123c516a PC |
782 | static true_type __test(int); |
783 | ||
784 | template<typename> | |
785 | static false_type __test(...); | |
786 | }; | |
53dc5044 PC |
787 | |
788 | template<typename _Tp> | |
62fa805f DK |
789 | struct __is_destructible_impl |
790 | : public __do_is_destructible_impl | |
123c516a PC |
791 | { |
792 | typedef decltype(__test<_Tp>(0)) type; | |
793 | }; | |
53dc5044 | 794 | |
62fa805f DK |
795 | template<typename _Tp, |
796 | bool = __or_<is_void<_Tp>, | |
797 | __is_array_unknown_bounds<_Tp>, | |
798 | is_function<_Tp>>::value, | |
799 | bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> | |
800 | struct __is_destructible_safe; | |
801 | ||
802 | template<typename _Tp> | |
803 | struct __is_destructible_safe<_Tp, false, false> | |
804 | : public __is_destructible_impl<typename | |
805 | remove_all_extents<_Tp>::type>::type | |
806 | { }; | |
807 | ||
808 | template<typename _Tp> | |
809 | struct __is_destructible_safe<_Tp, true, false> | |
810 | : public false_type { }; | |
811 | ||
812 | template<typename _Tp> | |
813 | struct __is_destructible_safe<_Tp, false, true> | |
814 | : public true_type { }; | |
815 | ||
816 | /// is_destructible | |
817 | template<typename _Tp> | |
818 | struct is_destructible | |
82b12c4b | 819 | : public __is_destructible_safe<_Tp>::type |
62fa805f DK |
820 | { }; |
821 | ||
822 | // is_nothrow_destructible requires that is_destructible is | |
823 | // satisfied as well. We realize that by mimicing the | |
824 | // implementation of is_destructible but refer to noexcept(expr) | |
825 | // instead of decltype(expr). | |
826 | struct __do_is_nt_destructible_impl | |
123c516a | 827 | { |
62fa805f DK |
828 | template<typename _Tp> |
829 | static integral_constant<bool, noexcept(declval<_Tp&>().~_Tp())> | |
830 | __test(int); | |
123c516a PC |
831 | |
832 | template<typename> | |
833 | static false_type __test(...); | |
834 | }; | |
53dc5044 | 835 | |
53dc5044 | 836 | template<typename _Tp> |
62fa805f DK |
837 | struct __is_nt_destructible_impl |
838 | : public __do_is_nt_destructible_impl | |
123c516a PC |
839 | { |
840 | typedef decltype(__test<_Tp>(0)) type; | |
841 | }; | |
842 | ||
843 | template<typename _Tp, | |
844 | bool = __or_<is_void<_Tp>, | |
62fa805f DK |
845 | __is_array_unknown_bounds<_Tp>, |
846 | is_function<_Tp>>::value, | |
847 | bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> | |
848 | struct __is_nt_destructible_safe; | |
53dc5044 PC |
849 | |
850 | template<typename _Tp> | |
62fa805f DK |
851 | struct __is_nt_destructible_safe<_Tp, false, false> |
852 | : public __is_nt_destructible_impl<typename | |
853 | remove_all_extents<_Tp>::type>::type | |
123c516a PC |
854 | { }; |
855 | ||
53dc5044 | 856 | template<typename _Tp> |
62fa805f | 857 | struct __is_nt_destructible_safe<_Tp, true, false> |
123c516a | 858 | : public false_type { }; |
53dc5044 PC |
859 | |
860 | template<typename _Tp> | |
62fa805f | 861 | struct __is_nt_destructible_safe<_Tp, false, true> |
123c516a PC |
862 | : public true_type { }; |
863 | ||
62fa805f | 864 | /// is_nothrow_destructible |
53dc5044 | 865 | template<typename _Tp> |
62fa805f | 866 | struct is_nothrow_destructible |
82b12c4b | 867 | : public __is_nt_destructible_safe<_Tp>::type |
123c516a PC |
868 | { }; |
869 | ||
870 | struct __do_is_default_constructible_impl | |
871 | { | |
872 | template<typename _Tp, typename = decltype(_Tp())> | |
873 | static true_type __test(int); | |
874 | ||
875 | template<typename> | |
876 | static false_type __test(...); | |
877 | }; | |
878 | ||
879 | template<typename _Tp> | |
880 | struct __is_default_constructible_impl | |
881 | : public __do_is_default_constructible_impl | |
53dc5044 | 882 | { |
123c516a | 883 | typedef decltype(__test<_Tp>(0)) type; |
53dc5044 | 884 | }; |
53dc5044 PC |
885 | |
886 | template<typename _Tp> | |
123c516a | 887 | struct __is_default_constructible_atom |
2c7a09d7 | 888 | : public __and_<__not_<is_void<_Tp>>, |
f7632193 | 889 | __is_default_constructible_impl<_Tp>> |
123c516a | 890 | { }; |
53dc5044 | 891 | |
123c516a PC |
892 | template<typename _Tp, bool = is_array<_Tp>::value> |
893 | struct __is_default_constructible_safe; | |
53dc5044 | 894 | |
2c7a09d7 | 895 | // The following technique is a workaround for a current core language |
33ac58d5 | 896 | // restriction, which does not allow for array types to occur in |
2c7a09d7 | 897 | // functional casts of the form T(). Complete arrays can be default- |
33ac58d5 | 898 | // constructed, if the element type is default-constructible, but |
2c7a09d7 | 899 | // arrays with unknown bounds are not. |
53dc5044 | 900 | template<typename _Tp> |
123c516a PC |
901 | struct __is_default_constructible_safe<_Tp, true> |
902 | : public __and_<__is_array_known_bounds<_Tp>, | |
903 | __is_default_constructible_atom<typename | |
f7632193 | 904 | remove_all_extents<_Tp>::type>> |
53dc5044 PC |
905 | { }; |
906 | ||
53dc5044 | 907 | template<typename _Tp> |
123c516a PC |
908 | struct __is_default_constructible_safe<_Tp, false> |
909 | : public __is_default_constructible_atom<_Tp>::type | |
910 | { }; | |
4a27a739 | 911 | |
123c516a | 912 | /// is_default_constructible |
4a27a739 | 913 | template<typename _Tp> |
123c516a | 914 | struct is_default_constructible |
82b12c4b | 915 | : public __is_default_constructible_safe<_Tp>::type |
123c516a | 916 | { }; |
4a27a739 | 917 | |
b0302c68 | 918 | /// is_constructible |
b0302c68 PC |
919 | template<typename _Tp, typename... _Args> |
920 | struct is_constructible | |
b42cc3ca | 921 | : public __bool_constant<__is_constructible(_Tp, _Args...)> |
c32097d8 JM |
922 | { }; |
923 | ||
89898034 | 924 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
65cee9bd | 925 | struct __is_copy_constructible_impl; |
123c516a | 926 | |
65cee9bd | 927 | template<typename _Tp> |
89898034 | 928 | struct __is_copy_constructible_impl<_Tp, false> |
65cee9bd PC |
929 | : public false_type { }; |
930 | ||
931 | template<typename _Tp> | |
89898034 | 932 | struct __is_copy_constructible_impl<_Tp, true> |
65cee9bd PC |
933 | : public is_constructible<_Tp, const _Tp&> |
934 | { }; | |
935 | ||
936 | /// is_copy_constructible | |
937 | template<typename _Tp> | |
938 | struct is_copy_constructible | |
939 | : public __is_copy_constructible_impl<_Tp> | |
940 | { }; | |
941 | ||
89898034 | 942 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
65cee9bd PC |
943 | struct __is_move_constructible_impl; |
944 | ||
945 | template<typename _Tp> | |
89898034 | 946 | struct __is_move_constructible_impl<_Tp, false> |
65cee9bd PC |
947 | : public false_type { }; |
948 | ||
949 | template<typename _Tp> | |
89898034 | 950 | struct __is_move_constructible_impl<_Tp, true> |
65cee9bd PC |
951 | : public is_constructible<_Tp, _Tp&&> |
952 | { }; | |
953 | ||
954 | /// is_move_constructible | |
955 | template<typename _Tp> | |
956 | struct is_move_constructible | |
957 | : public __is_move_constructible_impl<_Tp> | |
958 | { }; | |
959 | ||
960 | template<typename _Tp> | |
961 | struct __is_nt_default_constructible_atom | |
962 | : public integral_constant<bool, noexcept(_Tp())> | |
963 | { }; | |
964 | ||
965 | template<typename _Tp, bool = is_array<_Tp>::value> | |
966 | struct __is_nt_default_constructible_impl; | |
967 | ||
968 | template<typename _Tp> | |
969 | struct __is_nt_default_constructible_impl<_Tp, true> | |
970 | : public __and_<__is_array_known_bounds<_Tp>, | |
971 | __is_nt_default_constructible_atom<typename | |
f7632193 | 972 | remove_all_extents<_Tp>::type>> |
65cee9bd PC |
973 | { }; |
974 | ||
975 | template<typename _Tp> | |
976 | struct __is_nt_default_constructible_impl<_Tp, false> | |
977 | : public __is_nt_default_constructible_atom<_Tp> | |
978 | { }; | |
979 | ||
980 | /// is_nothrow_default_constructible | |
981 | template<typename _Tp> | |
982 | struct is_nothrow_default_constructible | |
983 | : public __and_<is_default_constructible<_Tp>, | |
f7632193 | 984 | __is_nt_default_constructible_impl<_Tp>> |
65cee9bd | 985 | { }; |
e4f32cb0 PC |
986 | |
987 | template<typename _Tp, typename... _Args> | |
65cee9bd PC |
988 | struct __is_nt_constructible_impl |
989 | : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> | |
990 | { }; | |
e4f32cb0 PC |
991 | |
992 | template<typename _Tp, typename _Arg> | |
65cee9bd PC |
993 | struct __is_nt_constructible_impl<_Tp, _Arg> |
994 | : public integral_constant<bool, | |
995 | noexcept(static_cast<_Tp>(declval<_Arg>()))> | |
996 | { }; | |
997 | ||
998 | template<typename _Tp> | |
999 | struct __is_nt_constructible_impl<_Tp> | |
1000 | : public is_nothrow_default_constructible<_Tp> | |
1001 | { }; | |
e4f32cb0 PC |
1002 | |
1003 | /// is_nothrow_constructible | |
1004 | template<typename _Tp, typename... _Args> | |
1005 | struct is_nothrow_constructible | |
65cee9bd | 1006 | : public __and_<is_constructible<_Tp, _Args...>, |
f7632193 | 1007 | __is_nt_constructible_impl<_Tp, _Args...>> |
65cee9bd PC |
1008 | { }; |
1009 | ||
89898034 | 1010 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
65cee9bd PC |
1011 | struct __is_nothrow_copy_constructible_impl; |
1012 | ||
1013 | template<typename _Tp> | |
89898034 | 1014 | struct __is_nothrow_copy_constructible_impl<_Tp, false> |
65cee9bd PC |
1015 | : public false_type { }; |
1016 | ||
1017 | template<typename _Tp> | |
89898034 | 1018 | struct __is_nothrow_copy_constructible_impl<_Tp, true> |
65cee9bd PC |
1019 | : public is_nothrow_constructible<_Tp, const _Tp&> |
1020 | { }; | |
1021 | ||
1022 | /// is_nothrow_copy_constructible | |
1023 | template<typename _Tp> | |
1024 | struct is_nothrow_copy_constructible | |
1025 | : public __is_nothrow_copy_constructible_impl<_Tp> | |
1026 | { }; | |
1027 | ||
89898034 | 1028 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
65cee9bd PC |
1029 | struct __is_nothrow_move_constructible_impl; |
1030 | ||
1031 | template<typename _Tp> | |
89898034 | 1032 | struct __is_nothrow_move_constructible_impl<_Tp, false> |
65cee9bd PC |
1033 | : public false_type { }; |
1034 | ||
1035 | template<typename _Tp> | |
89898034 | 1036 | struct __is_nothrow_move_constructible_impl<_Tp, true> |
65cee9bd PC |
1037 | : public is_nothrow_constructible<_Tp, _Tp&&> |
1038 | { }; | |
1039 | ||
1040 | /// is_nothrow_move_constructible | |
1041 | template<typename _Tp> | |
1042 | struct is_nothrow_move_constructible | |
1043 | : public __is_nothrow_move_constructible_impl<_Tp> | |
1044 | { }; | |
1045 | ||
f263981a PC |
1046 | /// is_assignable |
1047 | template<typename _Tp, typename _Up> | |
1048 | struct is_assignable | |
b42cc3ca | 1049 | : public __bool_constant<__is_assignable(_Tp, _Up)> |
f263981a PC |
1050 | { }; |
1051 | ||
89898034 | 1052 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
f263981a PC |
1053 | struct __is_copy_assignable_impl; |
1054 | ||
1055 | template<typename _Tp> | |
89898034 | 1056 | struct __is_copy_assignable_impl<_Tp, false> |
f263981a PC |
1057 | : public false_type { }; |
1058 | ||
1059 | template<typename _Tp> | |
89898034 | 1060 | struct __is_copy_assignable_impl<_Tp, true> |
9b3a81da | 1061 | : public is_assignable<_Tp&, const _Tp&> |
f263981a PC |
1062 | { }; |
1063 | ||
1064 | /// is_copy_assignable | |
1065 | template<typename _Tp> | |
1066 | struct is_copy_assignable | |
1067 | : public __is_copy_assignable_impl<_Tp> | |
1068 | { }; | |
1069 | ||
89898034 | 1070 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
f263981a PC |
1071 | struct __is_move_assignable_impl; |
1072 | ||
1073 | template<typename _Tp> | |
89898034 | 1074 | struct __is_move_assignable_impl<_Tp, false> |
f263981a PC |
1075 | : public false_type { }; |
1076 | ||
1077 | template<typename _Tp> | |
89898034 | 1078 | struct __is_move_assignable_impl<_Tp, true> |
f263981a PC |
1079 | : public is_assignable<_Tp&, _Tp&&> |
1080 | { }; | |
1081 | ||
1082 | /// is_move_assignable | |
1083 | template<typename _Tp> | |
1084 | struct is_move_assignable | |
1085 | : public __is_move_assignable_impl<_Tp> | |
1086 | { }; | |
1087 | ||
1088 | template<typename _Tp, typename _Up> | |
1089 | struct __is_nt_assignable_impl | |
1090 | : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())> | |
1091 | { }; | |
1092 | ||
1093 | /// is_nothrow_assignable | |
1094 | template<typename _Tp, typename _Up> | |
1095 | struct is_nothrow_assignable | |
1096 | : public __and_<is_assignable<_Tp, _Up>, | |
f7632193 | 1097 | __is_nt_assignable_impl<_Tp, _Up>> |
f263981a PC |
1098 | { }; |
1099 | ||
89898034 | 1100 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
f263981a PC |
1101 | struct __is_nt_copy_assignable_impl; |
1102 | ||
1103 | template<typename _Tp> | |
89898034 | 1104 | struct __is_nt_copy_assignable_impl<_Tp, false> |
f263981a PC |
1105 | : public false_type { }; |
1106 | ||
1107 | template<typename _Tp> | |
89898034 | 1108 | struct __is_nt_copy_assignable_impl<_Tp, true> |
9b3a81da | 1109 | : public is_nothrow_assignable<_Tp&, const _Tp&> |
f263981a PC |
1110 | { }; |
1111 | ||
1112 | /// is_nothrow_copy_assignable | |
1113 | template<typename _Tp> | |
1114 | struct is_nothrow_copy_assignable | |
1115 | : public __is_nt_copy_assignable_impl<_Tp> | |
1116 | { }; | |
1117 | ||
89898034 | 1118 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
f263981a PC |
1119 | struct __is_nt_move_assignable_impl; |
1120 | ||
1121 | template<typename _Tp> | |
89898034 | 1122 | struct __is_nt_move_assignable_impl<_Tp, false> |
f263981a PC |
1123 | : public false_type { }; |
1124 | ||
1125 | template<typename _Tp> | |
89898034 | 1126 | struct __is_nt_move_assignable_impl<_Tp, true> |
f263981a PC |
1127 | : public is_nothrow_assignable<_Tp&, _Tp&&> |
1128 | { }; | |
1129 | ||
1130 | /// is_nothrow_move_assignable | |
65cee9bd | 1131 | template<typename _Tp> |
f263981a PC |
1132 | struct is_nothrow_move_assignable |
1133 | : public __is_nt_move_assignable_impl<_Tp> | |
e4f32cb0 PC |
1134 | { }; |
1135 | ||
f5e523b7 VV |
1136 | /// is_trivially_constructible |
1137 | template<typename _Tp, typename... _Args> | |
1138 | struct is_trivially_constructible | |
e9029d55 JW |
1139 | : public __and_<is_constructible<_Tp, _Args...>, __bool_constant< |
1140 | __is_trivially_constructible(_Tp, _Args...)>>::type | |
f5e523b7 | 1141 | { }; |
33ac58d5 | 1142 | |
f5e523b7 VV |
1143 | /// is_trivially_default_constructible |
1144 | template<typename _Tp> | |
1145 | struct is_trivially_default_constructible | |
1146 | : public is_trivially_constructible<_Tp>::type | |
1147 | { }; | |
6a9ecd34 | 1148 | |
f7632193 VV |
1149 | struct __do_is_implicitly_default_constructible_impl |
1150 | { | |
1151 | template <typename _Tp> | |
1152 | static void __helper(const _Tp&); | |
1153 | ||
1154 | template <typename _Tp> | |
1155 | static true_type __test(const _Tp&, | |
1156 | decltype(__helper<const _Tp&>({}))* = 0); | |
1157 | ||
1158 | static false_type __test(...); | |
1159 | }; | |
1160 | ||
1161 | template<typename _Tp> | |
1162 | struct __is_implicitly_default_constructible_impl | |
e9029d55 JW |
1163 | : public __do_is_implicitly_default_constructible_impl |
1164 | { | |
1165 | typedef decltype(__test(declval<_Tp>())) type; | |
1166 | }; | |
f7632193 VV |
1167 | |
1168 | template<typename _Tp> | |
1169 | struct __is_implicitly_default_constructible_safe | |
e9029d55 JW |
1170 | : public __is_implicitly_default_constructible_impl<_Tp>::type |
1171 | { }; | |
f7632193 VV |
1172 | |
1173 | template <typename _Tp> | |
1174 | struct __is_implicitly_default_constructible | |
e9029d55 JW |
1175 | : public __and_<is_default_constructible<_Tp>, |
1176 | __is_implicitly_default_constructible_safe<_Tp>> | |
1177 | { }; | |
f7632193 | 1178 | |
f5e523b7 | 1179 | /// is_trivially_copy_constructible |
b42cc3ca VV |
1180 | |
1181 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> | |
1182 | struct __is_trivially_copy_constructible_impl; | |
1183 | ||
f5e523b7 | 1184 | template<typename _Tp> |
b42cc3ca VV |
1185 | struct __is_trivially_copy_constructible_impl<_Tp, false> |
1186 | : public false_type { }; | |
1187 | ||
1188 | template<typename _Tp> | |
1189 | struct __is_trivially_copy_constructible_impl<_Tp, true> | |
33ac58d5 | 1190 | : public __and_<is_copy_constructible<_Tp>, |
f5e523b7 | 1191 | integral_constant<bool, |
f7632193 | 1192 | __is_trivially_constructible(_Tp, const _Tp&)>> |
f5e523b7 | 1193 | { }; |
33ac58d5 | 1194 | |
b42cc3ca VV |
1195 | template<typename _Tp> |
1196 | struct is_trivially_copy_constructible | |
1197 | : public __is_trivially_copy_constructible_impl<_Tp> | |
1198 | { }; | |
1199 | ||
f5e523b7 | 1200 | /// is_trivially_move_constructible |
b42cc3ca VV |
1201 | |
1202 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> | |
1203 | struct __is_trivially_move_constructible_impl; | |
1204 | ||
f5e523b7 | 1205 | template<typename _Tp> |
b42cc3ca VV |
1206 | struct __is_trivially_move_constructible_impl<_Tp, false> |
1207 | : public false_type { }; | |
1208 | ||
1209 | template<typename _Tp> | |
1210 | struct __is_trivially_move_constructible_impl<_Tp, true> | |
33ac58d5 | 1211 | : public __and_<is_move_constructible<_Tp>, |
f5e523b7 | 1212 | integral_constant<bool, |
f7632193 | 1213 | __is_trivially_constructible(_Tp, _Tp&&)>> |
f5e523b7 | 1214 | { }; |
6a9ecd34 | 1215 | |
b42cc3ca VV |
1216 | template<typename _Tp> |
1217 | struct is_trivially_move_constructible | |
1218 | : public __is_trivially_move_constructible_impl<_Tp> | |
1219 | { }; | |
1220 | ||
f5e523b7 VV |
1221 | /// is_trivially_assignable |
1222 | template<typename _Tp, typename _Up> | |
1223 | struct is_trivially_assignable | |
b42cc3ca | 1224 | : public __bool_constant<__is_trivially_assignable(_Tp, _Up)> |
f5e523b7 | 1225 | { }; |
6a9ecd34 | 1226 | |
f5e523b7 | 1227 | /// is_trivially_copy_assignable |
b42cc3ca VV |
1228 | |
1229 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> | |
1230 | struct __is_trivially_copy_assignable_impl; | |
1231 | ||
f5e523b7 | 1232 | template<typename _Tp> |
b42cc3ca VV |
1233 | struct __is_trivially_copy_assignable_impl<_Tp, false> |
1234 | : public false_type { }; | |
1235 | ||
1236 | template<typename _Tp> | |
1237 | struct __is_trivially_copy_assignable_impl<_Tp, true> | |
33ac58d5 | 1238 | : public __and_<is_copy_assignable<_Tp>, |
f5e523b7 | 1239 | integral_constant<bool, |
f7632193 | 1240 | __is_trivially_assignable(_Tp&, const _Tp&)>> |
f5e523b7 | 1241 | { }; |
6a9ecd34 | 1242 | |
b42cc3ca VV |
1243 | template<typename _Tp> |
1244 | struct is_trivially_copy_assignable | |
1245 | : public __is_trivially_copy_assignable_impl<_Tp> | |
1246 | { }; | |
1247 | ||
f5e523b7 | 1248 | /// is_trivially_move_assignable |
b42cc3ca VV |
1249 | |
1250 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> | |
1251 | struct __is_trivially_move_assignable_impl; | |
1252 | ||
f5e523b7 | 1253 | template<typename _Tp> |
b42cc3ca VV |
1254 | struct __is_trivially_move_assignable_impl<_Tp, false> |
1255 | : public false_type { }; | |
1256 | ||
1257 | template<typename _Tp> | |
1258 | struct __is_trivially_move_assignable_impl<_Tp, true> | |
33ac58d5 | 1259 | : public __and_<is_move_assignable<_Tp>, |
f5e523b7 | 1260 | integral_constant<bool, |
f7632193 | 1261 | __is_trivially_assignable(_Tp&, _Tp&&)>> |
f5e523b7 | 1262 | { }; |
6a9ecd34 | 1263 | |
b42cc3ca VV |
1264 | template<typename _Tp> |
1265 | struct is_trivially_move_assignable | |
1266 | : public __is_trivially_move_assignable_impl<_Tp> | |
1267 | { }; | |
1268 | ||
6a9ecd34 PC |
1269 | /// is_trivially_destructible |
1270 | template<typename _Tp> | |
1271 | struct is_trivially_destructible | |
1272 | : public __and_<is_destructible<_Tp>, integral_constant<bool, | |
f7632193 | 1273 | __has_trivial_destructor(_Tp)>> |
6a9ecd34 PC |
1274 | { }; |
1275 | ||
e133ace8 | 1276 | |
123c516a PC |
1277 | /// has_virtual_destructor |
1278 | template<typename _Tp> | |
1279 | struct has_virtual_destructor | |
1280 | : public integral_constant<bool, __has_virtual_destructor(_Tp)> | |
1281 | { }; | |
1282 | ||
33ac58d5 | 1283 | |
123c516a PC |
1284 | // type property queries. |
1285 | ||
1286 | /// alignment_of | |
1287 | template<typename _Tp> | |
1288 | struct alignment_of | |
1289 | : public integral_constant<std::size_t, __alignof__(_Tp)> { }; | |
33ac58d5 | 1290 | |
123c516a PC |
1291 | /// rank |
1292 | template<typename> | |
1293 | struct rank | |
1294 | : public integral_constant<std::size_t, 0> { }; | |
33ac58d5 | 1295 | |
123c516a PC |
1296 | template<typename _Tp, std::size_t _Size> |
1297 | struct rank<_Tp[_Size]> | |
1298 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | |
1299 | ||
1300 | template<typename _Tp> | |
1301 | struct rank<_Tp[]> | |
1302 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | |
1303 | ||
1304 | /// extent | |
1305 | template<typename, unsigned _Uint> | |
1306 | struct extent | |
1307 | : public integral_constant<std::size_t, 0> { }; | |
33ac58d5 | 1308 | |
123c516a PC |
1309 | template<typename _Tp, unsigned _Uint, std::size_t _Size> |
1310 | struct extent<_Tp[_Size], _Uint> | |
1311 | : public integral_constant<std::size_t, | |
1312 | _Uint == 0 ? _Size : extent<_Tp, | |
1313 | _Uint - 1>::value> | |
1314 | { }; | |
1315 | ||
1316 | template<typename _Tp, unsigned _Uint> | |
1317 | struct extent<_Tp[], _Uint> | |
1318 | : public integral_constant<std::size_t, | |
1319 | _Uint == 0 ? 0 : extent<_Tp, | |
1320 | _Uint - 1>::value> | |
1321 | { }; | |
1322 | ||
1323 | ||
c0ffa2ba | 1324 | // Type relations. |
123c516a PC |
1325 | |
1326 | /// is_same | |
1327 | template<typename, typename> | |
1328 | struct is_same | |
1329 | : public false_type { }; | |
1330 | ||
1331 | template<typename _Tp> | |
1332 | struct is_same<_Tp, _Tp> | |
1333 | : public true_type { }; | |
b0302c68 | 1334 | |
939759fc | 1335 | /// is_base_of |
e133ace8 PC |
1336 | template<typename _Base, typename _Derived> |
1337 | struct is_base_of | |
1338 | : public integral_constant<bool, __is_base_of(_Base, _Derived)> | |
1339 | { }; | |
1340 | ||
297f34d7 | 1341 | template<typename _From, typename _To, |
123c516a PC |
1342 | bool = __or_<is_void<_From>, is_function<_To>, |
1343 | is_array<_To>>::value> | |
297f34d7 | 1344 | struct __is_convertible_helper |
8df27fcb JW |
1345 | { |
1346 | typedef typename is_void<_To>::type type; | |
1347 | #if __cplusplus > 201703L | |
1348 | typedef type __is_nothrow_type; | |
1349 | #endif | |
1350 | }; | |
297f34d7 | 1351 | |
e133ace8 | 1352 | template<typename _From, typename _To> |
b0302c68 | 1353 | class __is_convertible_helper<_From, _To, false> |
e133ace8 | 1354 | { |
8df27fcb JW |
1355 | template<typename _To1> |
1356 | static void __test_aux(_To1) noexcept; | |
8e7d962a | 1357 | |
82b12c4b FD |
1358 | template<typename _From1, typename _To1, |
1359 | typename = decltype(__test_aux<_To1>(std::declval<_From1>()))> | |
1360 | static true_type | |
8e7d962a PC |
1361 | __test(int); |
1362 | ||
1363 | template<typename, typename> | |
82b12c4b FD |
1364 | static false_type |
1365 | __test(...); | |
297f34d7 | 1366 | |
8df27fcb JW |
1367 | #if __cplusplus > 201703L |
1368 | template<typename _From1, typename _To1, | |
1369 | bool _NoEx = noexcept(__test_aux<_To1>(std::declval<_From1>()))> | |
1370 | static __bool_constant<_NoEx> | |
1371 | __test_nothrow(int); | |
1372 | ||
1373 | template<typename, typename> | |
1374 | static false_type | |
1375 | __test_nothrow(...); | |
1376 | #endif | |
1377 | ||
e133ace8 | 1378 | public: |
82b12c4b | 1379 | typedef decltype(__test<_From, _To>(0)) type; |
8df27fcb JW |
1380 | |
1381 | #if __cplusplus > 201703L | |
1382 | typedef decltype(__test_nothrow<_From, _To>(0)) __is_nothrow_type; | |
1383 | #endif | |
e133ace8 PC |
1384 | }; |
1385 | ||
82b12c4b | 1386 | |
b0302c68 | 1387 | /// is_convertible |
e133ace8 PC |
1388 | template<typename _From, typename _To> |
1389 | struct is_convertible | |
82b12c4b | 1390 | : public __is_convertible_helper<_From, _To>::type |
e133ace8 PC |
1391 | { }; |
1392 | ||
8df27fcb JW |
1393 | #if __cplusplus > 201703L |
1394 | /// is_nothrow_convertible | |
1395 | template<typename _From, typename _To> | |
1396 | struct is_nothrow_convertible | |
1397 | : public __is_convertible_helper<_From, _To>::__is_nothrow_type | |
1398 | { }; | |
1399 | ||
1400 | /// is_nothrow_convertible_v | |
1401 | template<typename _From, typename _To> | |
1402 | inline constexpr bool is_nothrow_convertible_v | |
1403 | = is_nothrow_convertible<_From, _To>::value; | |
1404 | #endif // C++2a | |
fd735b6a | 1405 | |
c0ffa2ba | 1406 | // Const-volatile modifications. |
7b50cdef | 1407 | |
123c516a | 1408 | /// remove_const |
7b50cdef | 1409 | template<typename _Tp> |
123c516a PC |
1410 | struct remove_const |
1411 | { typedef _Tp type; }; | |
7b50cdef | 1412 | |
123c516a PC |
1413 | template<typename _Tp> |
1414 | struct remove_const<_Tp const> | |
1415 | { typedef _Tp type; }; | |
33ac58d5 | 1416 | |
123c516a PC |
1417 | /// remove_volatile |
1418 | template<typename _Tp> | |
1419 | struct remove_volatile | |
1420 | { typedef _Tp type; }; | |
7b50cdef | 1421 | |
123c516a PC |
1422 | template<typename _Tp> |
1423 | struct remove_volatile<_Tp volatile> | |
1424 | { typedef _Tp type; }; | |
33ac58d5 | 1425 | |
123c516a PC |
1426 | /// remove_cv |
1427 | template<typename _Tp> | |
1428 | struct remove_cv | |
1429 | { | |
1430 | typedef typename | |
1431 | remove_const<typename remove_volatile<_Tp>::type>::type type; | |
1432 | }; | |
33ac58d5 | 1433 | |
123c516a PC |
1434 | /// add_const |
1435 | template<typename _Tp> | |
1436 | struct add_const | |
1437 | { typedef _Tp const type; }; | |
33ac58d5 | 1438 | |
123c516a PC |
1439 | /// add_volatile |
1440 | template<typename _Tp> | |
1441 | struct add_volatile | |
1442 | { typedef _Tp volatile type; }; | |
33ac58d5 | 1443 | |
123c516a PC |
1444 | /// add_cv |
1445 | template<typename _Tp> | |
1446 | struct add_cv | |
1447 | { | |
1448 | typedef typename | |
1449 | add_const<typename add_volatile<_Tp>::type>::type type; | |
1450 | }; | |
7b50cdef | 1451 | |
4457e88c | 1452 | #if __cplusplus > 201103L |
a15f7cb8 ESR |
1453 | |
1454 | #define __cpp_lib_transformation_trait_aliases 201304 | |
1455 | ||
4457e88c JW |
1456 | /// Alias template for remove_const |
1457 | template<typename _Tp> | |
1458 | using remove_const_t = typename remove_const<_Tp>::type; | |
1459 | ||
1460 | /// Alias template for remove_volatile | |
1461 | template<typename _Tp> | |
1462 | using remove_volatile_t = typename remove_volatile<_Tp>::type; | |
1463 | ||
1464 | /// Alias template for remove_cv | |
1465 | template<typename _Tp> | |
1466 | using remove_cv_t = typename remove_cv<_Tp>::type; | |
1467 | ||
1468 | /// Alias template for add_const | |
1469 | template<typename _Tp> | |
1470 | using add_const_t = typename add_const<_Tp>::type; | |
1471 | ||
1472 | /// Alias template for add_volatile | |
1473 | template<typename _Tp> | |
1474 | using add_volatile_t = typename add_volatile<_Tp>::type; | |
1475 | ||
1476 | /// Alias template for add_cv | |
1477 | template<typename _Tp> | |
1478 | using add_cv_t = typename add_cv<_Tp>::type; | |
1479 | #endif | |
7b50cdef | 1480 | |
123c516a | 1481 | // Reference transformations. |
7b50cdef | 1482 | |
123c516a PC |
1483 | /// remove_reference |
1484 | template<typename _Tp> | |
1485 | struct remove_reference | |
1486 | { typedef _Tp type; }; | |
7b50cdef | 1487 | |
123c516a PC |
1488 | template<typename _Tp> |
1489 | struct remove_reference<_Tp&> | |
1490 | { typedef _Tp type; }; | |
7b50cdef | 1491 | |
123c516a PC |
1492 | template<typename _Tp> |
1493 | struct remove_reference<_Tp&&> | |
1494 | { typedef _Tp type; }; | |
1495 | ||
89898034 | 1496 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
123c516a PC |
1497 | struct __add_lvalue_reference_helper |
1498 | { typedef _Tp type; }; | |
7b50cdef | 1499 | |
5e108459 | 1500 | template<typename _Tp> |
89898034 | 1501 | struct __add_lvalue_reference_helper<_Tp, true> |
123c516a | 1502 | { typedef _Tp& type; }; |
5e108459 | 1503 | |
123c516a | 1504 | /// add_lvalue_reference |
5e108459 | 1505 | template<typename _Tp> |
123c516a PC |
1506 | struct add_lvalue_reference |
1507 | : public __add_lvalue_reference_helper<_Tp> | |
1508 | { }; | |
1509 | ||
89898034 | 1510 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
123c516a PC |
1511 | struct __add_rvalue_reference_helper |
1512 | { typedef _Tp type; }; | |
5e108459 PC |
1513 | |
1514 | template<typename _Tp> | |
123c516a PC |
1515 | struct __add_rvalue_reference_helper<_Tp, true> |
1516 | { typedef _Tp&& type; }; | |
5e108459 | 1517 | |
123c516a | 1518 | /// add_rvalue_reference |
5e108459 | 1519 | template<typename _Tp> |
123c516a PC |
1520 | struct add_rvalue_reference |
1521 | : public __add_rvalue_reference_helper<_Tp> | |
1522 | { }; | |
5e108459 | 1523 | |
4457e88c JW |
1524 | #if __cplusplus > 201103L |
1525 | /// Alias template for remove_reference | |
1526 | template<typename _Tp> | |
1527 | using remove_reference_t = typename remove_reference<_Tp>::type; | |
1528 | ||
1529 | /// Alias template for add_lvalue_reference | |
1530 | template<typename _Tp> | |
1531 | using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; | |
1532 | ||
1533 | /// Alias template for add_rvalue_reference | |
1534 | template<typename _Tp> | |
1535 | using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; | |
1536 | #endif | |
7b50cdef | 1537 | |
c0ffa2ba | 1538 | // Sign modifications. |
123c516a | 1539 | |
7b50cdef BK |
1540 | // Utility for constructing identically cv-qualified types. |
1541 | template<typename _Unqualified, bool _IsConst, bool _IsVol> | |
1542 | struct __cv_selector; | |
1543 | ||
1544 | template<typename _Unqualified> | |
1545 | struct __cv_selector<_Unqualified, false, false> | |
1546 | { typedef _Unqualified __type; }; | |
1547 | ||
1548 | template<typename _Unqualified> | |
1549 | struct __cv_selector<_Unqualified, false, true> | |
1550 | { typedef volatile _Unqualified __type; }; | |
1551 | ||
1552 | template<typename _Unqualified> | |
1553 | struct __cv_selector<_Unqualified, true, false> | |
1554 | { typedef const _Unqualified __type; }; | |
1555 | ||
1556 | template<typename _Unqualified> | |
1557 | struct __cv_selector<_Unqualified, true, true> | |
1558 | { typedef const volatile _Unqualified __type; }; | |
1559 | ||
1560 | template<typename _Qualified, typename _Unqualified, | |
1561 | bool _IsConst = is_const<_Qualified>::value, | |
1562 | bool _IsVol = is_volatile<_Qualified>::value> | |
b0302c68 | 1563 | class __match_cv_qualifiers |
7b50cdef | 1564 | { |
7b50cdef BK |
1565 | typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; |
1566 | ||
1567 | public: | |
33ac58d5 | 1568 | typedef typename __match::__type __type; |
7b50cdef BK |
1569 | }; |
1570 | ||
7b50cdef BK |
1571 | // Utility for finding the unsigned versions of signed integral types. |
1572 | template<typename _Tp> | |
e133ace8 PC |
1573 | struct __make_unsigned |
1574 | { typedef _Tp __type; }; | |
7b50cdef BK |
1575 | |
1576 | template<> | |
1577 | struct __make_unsigned<char> | |
1578 | { typedef unsigned char __type; }; | |
1579 | ||
1580 | template<> | |
1581 | struct __make_unsigned<signed char> | |
1582 | { typedef unsigned char __type; }; | |
1583 | ||
7b50cdef BK |
1584 | template<> |
1585 | struct __make_unsigned<short> | |
1586 | { typedef unsigned short __type; }; | |
1587 | ||
1588 | template<> | |
1589 | struct __make_unsigned<int> | |
1590 | { typedef unsigned int __type; }; | |
1591 | ||
1592 | template<> | |
1593 | struct __make_unsigned<long> | |
1594 | { typedef unsigned long __type; }; | |
1595 | ||
1596 | template<> | |
1597 | struct __make_unsigned<long long> | |
1598 | { typedef unsigned long long __type; }; | |
1599 | ||
78a7c317 DD |
1600 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
1601 | template<> | |
1602 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0> | |
1603 | { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; }; | |
1604 | #endif | |
1605 | #if defined(__GLIBCXX_TYPE_INT_N_1) | |
1606 | template<> | |
1607 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1> | |
1608 | { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; }; | |
1609 | #endif | |
1610 | #if defined(__GLIBCXX_TYPE_INT_N_2) | |
6d585f01 | 1611 | template<> |
78a7c317 DD |
1612 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2> |
1613 | { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; }; | |
1614 | #endif | |
1615 | #if defined(__GLIBCXX_TYPE_INT_N_3) | |
1616 | template<> | |
1617 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3> | |
1618 | { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; }; | |
6d585f01 PC |
1619 | #endif |
1620 | ||
7b50cdef | 1621 | // Select between integral and enum: not possible to be both. |
33ac58d5 | 1622 | template<typename _Tp, |
7b50cdef | 1623 | bool _IsInt = is_integral<_Tp>::value, |
7b50cdef | 1624 | bool _IsEnum = is_enum<_Tp>::value> |
b0302c68 PC |
1625 | class __make_unsigned_selector; |
1626 | ||
7b50cdef | 1627 | template<typename _Tp> |
b0302c68 | 1628 | class __make_unsigned_selector<_Tp, true, false> |
7b50cdef | 1629 | { |
22f1f4c7 JW |
1630 | using __unsigned_type |
1631 | = typename __make_unsigned<typename remove_cv<_Tp>::type>::__type; | |
7b50cdef BK |
1632 | |
1633 | public: | |
22f1f4c7 JW |
1634 | using __type |
1635 | = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; | |
7b50cdef BK |
1636 | }; |
1637 | ||
22f1f4c7 JW |
1638 | class __make_unsigned_selector_base |
1639 | { | |
1640 | protected: | |
1641 | template<typename...> struct _List { }; | |
1642 | ||
1643 | template<typename _Tp, typename... _Up> | |
1644 | struct _List<_Tp, _Up...> : _List<_Up...> | |
1645 | { static constexpr size_t __size = sizeof(_Tp); }; | |
1646 | ||
1647 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | |
1648 | struct __select; | |
1649 | ||
1650 | template<size_t _Sz, typename _Uint, typename... _UInts> | |
1651 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | |
1652 | { using __type = _Uint; }; | |
1653 | ||
1654 | template<size_t _Sz, typename _Uint, typename... _UInts> | |
1655 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | |
1656 | : __select<_Sz, _List<_UInts...>> | |
1657 | { }; | |
1658 | }; | |
1659 | ||
1660 | // Choose unsigned integer type with the smallest rank and same size as _Tp | |
7b50cdef | 1661 | template<typename _Tp> |
b0302c68 | 1662 | class __make_unsigned_selector<_Tp, false, true> |
22f1f4c7 | 1663 | : __make_unsigned_selector_base |
7b50cdef | 1664 | { |
a0230468 | 1665 | // With -fshort-enums, an enum may be as small as a char. |
22f1f4c7 JW |
1666 | using _UInts = _List<unsigned char, unsigned short, unsigned int, |
1667 | unsigned long, unsigned long long>; | |
1668 | ||
1669 | using __unsigned_type = typename __select<sizeof(_Tp), _UInts>::__type; | |
73d81d3a | 1670 | |
7b50cdef | 1671 | public: |
22f1f4c7 JW |
1672 | using __type |
1673 | = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; | |
1674 | }; | |
1675 | ||
1676 | // wchar_t, char16_t and char32_t are integral types but are neither | |
d4b695e4 | 1677 | // signed integer types nor unsigned integer types, so must be |
22f1f4c7 JW |
1678 | // transformed to the unsigned integer type with the smallest rank. |
1679 | // Use the partial specialization for enumeration types to do that. | |
1680 | #if defined(_GLIBCXX_USE_WCHAR_T) | |
1681 | template<> | |
1682 | struct __make_unsigned<wchar_t> | |
1683 | { | |
1684 | using __type | |
1685 | = typename __make_unsigned_selector<wchar_t, false, true>::__type; | |
1686 | }; | |
1687 | #endif | |
1688 | ||
1689 | template<> | |
1690 | struct __make_unsigned<char16_t> | |
1691 | { | |
1692 | using __type | |
1693 | = typename __make_unsigned_selector<char16_t, false, true>::__type; | |
1694 | }; | |
1695 | ||
1696 | template<> | |
1697 | struct __make_unsigned<char32_t> | |
1698 | { | |
1699 | using __type | |
1700 | = typename __make_unsigned_selector<char32_t, false, true>::__type; | |
7b50cdef BK |
1701 | }; |
1702 | ||
7b50cdef BK |
1703 | // Given an integral/enum type, return the corresponding unsigned |
1704 | // integer type. | |
5b9daa7e BK |
1705 | // Primary template. |
1706 | /// make_unsigned | |
7b50cdef | 1707 | template<typename _Tp> |
33ac58d5 | 1708 | struct make_unsigned |
7b50cdef BK |
1709 | { typedef typename __make_unsigned_selector<_Tp>::__type type; }; |
1710 | ||
1711 | // Integral, but don't define. | |
1712 | template<> | |
1713 | struct make_unsigned<bool>; | |
1714 | ||
1715 | ||
1716 | // Utility for finding the signed versions of unsigned integral types. | |
1717 | template<typename _Tp> | |
e133ace8 PC |
1718 | struct __make_signed |
1719 | { typedef _Tp __type; }; | |
7b50cdef BK |
1720 | |
1721 | template<> | |
1722 | struct __make_signed<char> | |
1723 | { typedef signed char __type; }; | |
1724 | ||
1725 | template<> | |
1726 | struct __make_signed<unsigned char> | |
1727 | { typedef signed char __type; }; | |
1728 | ||
7b50cdef BK |
1729 | template<> |
1730 | struct __make_signed<unsigned short> | |
1731 | { typedef signed short __type; }; | |
1732 | ||
1733 | template<> | |
1734 | struct __make_signed<unsigned int> | |
1735 | { typedef signed int __type; }; | |
1736 | ||
1737 | template<> | |
1738 | struct __make_signed<unsigned long> | |
1739 | { typedef signed long __type; }; | |
1740 | ||
1741 | template<> | |
1742 | struct __make_signed<unsigned long long> | |
1743 | { typedef signed long long __type; }; | |
1744 | ||
78a7c317 DD |
1745 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
1746 | template<> | |
1747 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0> | |
1748 | { typedef __GLIBCXX_TYPE_INT_N_0 __type; }; | |
1749 | #endif | |
1750 | #if defined(__GLIBCXX_TYPE_INT_N_1) | |
1751 | template<> | |
1752 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1> | |
1753 | { typedef __GLIBCXX_TYPE_INT_N_1 __type; }; | |
1754 | #endif | |
1755 | #if defined(__GLIBCXX_TYPE_INT_N_2) | |
1756 | template<> | |
1757 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2> | |
1758 | { typedef __GLIBCXX_TYPE_INT_N_2 __type; }; | |
1759 | #endif | |
1760 | #if defined(__GLIBCXX_TYPE_INT_N_3) | |
6d585f01 | 1761 | template<> |
78a7c317 DD |
1762 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3> |
1763 | { typedef __GLIBCXX_TYPE_INT_N_3 __type; }; | |
6d585f01 PC |
1764 | #endif |
1765 | ||
fb8ffd10 | 1766 | // Select between integral and enum: not possible to be both. |
33ac58d5 | 1767 | template<typename _Tp, |
7b50cdef | 1768 | bool _IsInt = is_integral<_Tp>::value, |
7b50cdef | 1769 | bool _IsEnum = is_enum<_Tp>::value> |
b0302c68 PC |
1770 | class __make_signed_selector; |
1771 | ||
7b50cdef | 1772 | template<typename _Tp> |
b0302c68 | 1773 | class __make_signed_selector<_Tp, true, false> |
7b50cdef | 1774 | { |
22f1f4c7 JW |
1775 | using __signed_type |
1776 | = typename __make_signed<typename remove_cv<_Tp>::type>::__type; | |
7b50cdef BK |
1777 | |
1778 | public: | |
22f1f4c7 JW |
1779 | using __type |
1780 | = typename __match_cv_qualifiers<_Tp, __signed_type>::__type; | |
7b50cdef BK |
1781 | }; |
1782 | ||
22f1f4c7 | 1783 | // Choose signed integer type with the smallest rank and same size as _Tp |
7b50cdef | 1784 | template<typename _Tp> |
b0302c68 | 1785 | class __make_signed_selector<_Tp, false, true> |
7b50cdef | 1786 | { |
73d81d3a | 1787 | typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type; |
7b50cdef BK |
1788 | |
1789 | public: | |
73d81d3a | 1790 | typedef typename __make_signed_selector<__unsigned_type>::__type __type; |
7b50cdef BK |
1791 | }; |
1792 | ||
22f1f4c7 | 1793 | // wchar_t, char16_t and char32_t are integral types but are neither |
d4b695e4 | 1794 | // signed integer types nor unsigned integer types, so must be |
22f1f4c7 JW |
1795 | // transformed to the signed integer type with the smallest rank. |
1796 | // Use the partial specialization for enumeration types to do that. | |
1797 | #if defined(_GLIBCXX_USE_WCHAR_T) | |
1798 | template<> | |
1799 | struct __make_signed<wchar_t> | |
1800 | { | |
1801 | using __type | |
1802 | = typename __make_signed_selector<wchar_t, false, true>::__type; | |
1803 | }; | |
1804 | #endif | |
1805 | ||
1806 | template<> | |
1807 | struct __make_signed<char16_t> | |
1808 | { | |
1809 | using __type | |
1810 | = typename __make_signed_selector<char16_t, false, true>::__type; | |
1811 | }; | |
1812 | ||
1813 | template<> | |
1814 | struct __make_signed<char32_t> | |
1815 | { | |
1816 | using __type | |
1817 | = typename __make_signed_selector<char32_t, false, true>::__type; | |
1818 | }; | |
1819 | ||
7b50cdef BK |
1820 | // Given an integral/enum type, return the corresponding signed |
1821 | // integer type. | |
5b9daa7e BK |
1822 | // Primary template. |
1823 | /// make_signed | |
7b50cdef | 1824 | template<typename _Tp> |
33ac58d5 | 1825 | struct make_signed |
7b50cdef BK |
1826 | { typedef typename __make_signed_selector<_Tp>::__type type; }; |
1827 | ||
1828 | // Integral, but don't define. | |
1829 | template<> | |
1830 | struct make_signed<bool>; | |
cfa9a96b | 1831 | |
4457e88c JW |
1832 | #if __cplusplus > 201103L |
1833 | /// Alias template for make_signed | |
1834 | template<typename _Tp> | |
1835 | using make_signed_t = typename make_signed<_Tp>::type; | |
1836 | ||
1837 | /// Alias template for make_unsigned | |
1838 | template<typename _Tp> | |
1839 | using make_unsigned_t = typename make_unsigned<_Tp>::type; | |
1840 | #endif | |
123c516a | 1841 | |
c0ffa2ba | 1842 | // Array modifications. |
123c516a PC |
1843 | |
1844 | /// remove_extent | |
1845 | template<typename _Tp> | |
1846 | struct remove_extent | |
1847 | { typedef _Tp type; }; | |
1848 | ||
1849 | template<typename _Tp, std::size_t _Size> | |
1850 | struct remove_extent<_Tp[_Size]> | |
1851 | { typedef _Tp type; }; | |
1852 | ||
1853 | template<typename _Tp> | |
1854 | struct remove_extent<_Tp[]> | |
1855 | { typedef _Tp type; }; | |
1856 | ||
1857 | /// remove_all_extents | |
1858 | template<typename _Tp> | |
1859 | struct remove_all_extents | |
1860 | { typedef _Tp type; }; | |
1861 | ||
1862 | template<typename _Tp, std::size_t _Size> | |
1863 | struct remove_all_extents<_Tp[_Size]> | |
1864 | { typedef typename remove_all_extents<_Tp>::type type; }; | |
1865 | ||
1866 | template<typename _Tp> | |
1867 | struct remove_all_extents<_Tp[]> | |
1868 | { typedef typename remove_all_extents<_Tp>::type type; }; | |
1869 | ||
4457e88c JW |
1870 | #if __cplusplus > 201103L |
1871 | /// Alias template for remove_extent | |
1872 | template<typename _Tp> | |
1873 | using remove_extent_t = typename remove_extent<_Tp>::type; | |
1874 | ||
1875 | /// Alias template for remove_all_extents | |
1876 | template<typename _Tp> | |
1877 | using remove_all_extents_t = typename remove_all_extents<_Tp>::type; | |
1878 | #endif | |
123c516a | 1879 | |
c0ffa2ba | 1880 | // Pointer modifications. |
123c516a PC |
1881 | |
1882 | template<typename _Tp, typename> | |
1883 | struct __remove_pointer_helper | |
1884 | { typedef _Tp type; }; | |
1885 | ||
1886 | template<typename _Tp, typename _Up> | |
1887 | struct __remove_pointer_helper<_Tp, _Up*> | |
1888 | { typedef _Up type; }; | |
1889 | ||
1890 | /// remove_pointer | |
1891 | template<typename _Tp> | |
1892 | struct remove_pointer | |
1893 | : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type> | |
1894 | { }; | |
1895 | ||
1896 | /// add_pointer | |
89898034 DK |
1897 | template<typename _Tp, bool = __or_<__is_referenceable<_Tp>, |
1898 | is_void<_Tp>>::value> | |
1899 | struct __add_pointer_helper | |
1900 | { typedef _Tp type; }; | |
1901 | ||
123c516a | 1902 | template<typename _Tp> |
89898034 | 1903 | struct __add_pointer_helper<_Tp, true> |
123c516a PC |
1904 | { typedef typename remove_reference<_Tp>::type* type; }; |
1905 | ||
89898034 | 1906 | template<typename _Tp> |
33ac58d5 | 1907 | struct add_pointer |
89898034 DK |
1908 | : public __add_pointer_helper<_Tp> |
1909 | { }; | |
1910 | ||
4457e88c JW |
1911 | #if __cplusplus > 201103L |
1912 | /// Alias template for remove_pointer | |
1913 | template<typename _Tp> | |
1914 | using remove_pointer_t = typename remove_pointer<_Tp>::type; | |
1915 | ||
1916 | /// Alias template for add_pointer | |
1917 | template<typename _Tp> | |
1918 | using add_pointer_t = typename add_pointer<_Tp>::type; | |
1919 | #endif | |
123c516a PC |
1920 | |
1921 | template<std::size_t _Len> | |
1922 | struct __aligned_storage_msa | |
33ac58d5 | 1923 | { |
123c516a PC |
1924 | union __type |
1925 | { | |
1926 | unsigned char __data[_Len]; | |
33ac58d5 | 1927 | struct __attribute__((__aligned__)) { } __align; |
123c516a PC |
1928 | }; |
1929 | }; | |
1930 | ||
1931 | /** | |
1932 | * @brief Alignment type. | |
1933 | * | |
1934 | * The value of _Align is a default-alignment which shall be the | |
1935 | * most stringent alignment requirement for any C++ object type | |
1936 | * whose size is no greater than _Len (3.9). The member typedef | |
1937 | * type shall be a POD type suitable for use as uninitialized | |
1938 | * storage for any object whose size is at most _Len and whose | |
1939 | * alignment is a divisor of _Align. | |
1940 | */ | |
1941 | template<std::size_t _Len, std::size_t _Align = | |
1942 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | |
1943 | struct aligned_storage | |
33ac58d5 | 1944 | { |
123c516a PC |
1945 | union type |
1946 | { | |
1947 | unsigned char __data[_Len]; | |
33ac58d5 | 1948 | struct __attribute__((__aligned__((_Align)))) { } __align; |
123c516a PC |
1949 | }; |
1950 | }; | |
1951 | ||
d3718027 RS |
1952 | template <typename... _Types> |
1953 | struct __strictest_alignment | |
1954 | { | |
1955 | static const size_t _S_alignment = 0; | |
1956 | static const size_t _S_size = 0; | |
1957 | }; | |
1958 | ||
1959 | template <typename _Tp, typename... _Types> | |
1960 | struct __strictest_alignment<_Tp, _Types...> | |
1961 | { | |
1962 | static const size_t _S_alignment = | |
1963 | alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment | |
1964 | ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment; | |
1965 | static const size_t _S_size = | |
1966 | sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size | |
1967 | ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size; | |
1968 | }; | |
1969 | ||
1970 | /** | |
1971 | * @brief Provide aligned storage for types. | |
1972 | * | |
1973 | * [meta.trans.other] | |
1974 | * | |
1975 | * Provides aligned storage for any of the provided types of at | |
1976 | * least size _Len. | |
1977 | * | |
1978 | * @see aligned_storage | |
1979 | */ | |
1980 | template <size_t _Len, typename... _Types> | |
1981 | struct aligned_union | |
1982 | { | |
1983 | private: | |
1984 | static_assert(sizeof...(_Types) != 0, "At least one type is required"); | |
1985 | ||
1986 | using __strictest = __strictest_alignment<_Types...>; | |
1987 | static const size_t _S_len = _Len > __strictest::_S_size | |
1988 | ? _Len : __strictest::_S_size; | |
1989 | public: | |
1990 | /// The value of the strictest alignment of _Types. | |
1991 | static const size_t alignment_value = __strictest::_S_alignment; | |
1992 | /// The storage. | |
1993 | typedef typename aligned_storage<_S_len, alignment_value>::type type; | |
1994 | }; | |
1995 | ||
1996 | template <size_t _Len, typename... _Types> | |
1997 | const size_t aligned_union<_Len, _Types...>::alignment_value; | |
123c516a PC |
1998 | |
1999 | // Decay trait for arrays and functions, used for perfect forwarding | |
2000 | // in make_pair, make_tuple, etc. | |
33ac58d5 | 2001 | template<typename _Up, |
123c516a | 2002 | bool _IsArray = is_array<_Up>::value, |
33ac58d5 | 2003 | bool _IsFunction = is_function<_Up>::value> |
123c516a PC |
2004 | struct __decay_selector; |
2005 | ||
2006 | // NB: DR 705. | |
33ac58d5 | 2007 | template<typename _Up> |
123c516a PC |
2008 | struct __decay_selector<_Up, false, false> |
2009 | { typedef typename remove_cv<_Up>::type __type; }; | |
2010 | ||
33ac58d5 | 2011 | template<typename _Up> |
123c516a PC |
2012 | struct __decay_selector<_Up, true, false> |
2013 | { typedef typename remove_extent<_Up>::type* __type; }; | |
2014 | ||
33ac58d5 | 2015 | template<typename _Up> |
123c516a PC |
2016 | struct __decay_selector<_Up, false, true> |
2017 | { typedef typename add_pointer<_Up>::type __type; }; | |
2018 | ||
2019 | /// decay | |
33ac58d5 JW |
2020 | template<typename _Tp> |
2021 | class decay | |
2022 | { | |
123c516a PC |
2023 | typedef typename remove_reference<_Tp>::type __remove_type; |
2024 | ||
2025 | public: | |
2026 | typedef typename __decay_selector<__remove_type>::__type type; | |
2027 | }; | |
2028 | ||
2029 | template<typename _Tp> | |
2030 | class reference_wrapper; | |
2031 | ||
2032 | // Helper which adds a reference to a type when given a reference_wrapper | |
2033 | template<typename _Tp> | |
2034 | struct __strip_reference_wrapper | |
2035 | { | |
2036 | typedef _Tp __type; | |
2037 | }; | |
2038 | ||
2039 | template<typename _Tp> | |
2040 | struct __strip_reference_wrapper<reference_wrapper<_Tp> > | |
2041 | { | |
2042 | typedef _Tp& __type; | |
2043 | }; | |
2044 | ||
123c516a PC |
2045 | template<typename _Tp> |
2046 | struct __decay_and_strip | |
2047 | { | |
2048 | typedef typename __strip_reference_wrapper< | |
2049 | typename decay<_Tp>::type>::__type __type; | |
2050 | }; | |
2051 | ||
2052 | ||
123c516a | 2053 | // Primary template. |
13901e4b | 2054 | /// Define a member typedef @c type only if a boolean constant is true. |
123c516a | 2055 | template<bool, typename _Tp = void> |
33ac58d5 | 2056 | struct enable_if |
123c516a PC |
2057 | { }; |
2058 | ||
2059 | // Partial specialization for true. | |
2060 | template<typename _Tp> | |
2061 | struct enable_if<true, _Tp> | |
2062 | { typedef _Tp type; }; | |
2063 | ||
23df8534 JW |
2064 | template<typename... _Cond> |
2065 | using _Require = typename enable_if<__and_<_Cond...>::value>::type; | |
123c516a | 2066 | |
123c516a | 2067 | // Primary template. |
13901e4b | 2068 | /// Define a member typedef @c type to one of two argument types. |
123c516a PC |
2069 | template<bool _Cond, typename _Iftrue, typename _Iffalse> |
2070 | struct conditional | |
2071 | { typedef _Iftrue type; }; | |
2072 | ||
2073 | // Partial specialization for false. | |
2074 | template<typename _Iftrue, typename _Iffalse> | |
2075 | struct conditional<false, _Iftrue, _Iffalse> | |
2076 | { typedef _Iffalse type; }; | |
2077 | ||
5b9daa7e | 2078 | /// common_type |
cfa9a96b CF |
2079 | template<typename... _Tp> |
2080 | struct common_type; | |
2081 | ||
c0ffa2ba | 2082 | // Sfinae-friendly common_type implementation: |
b3618b71 DK |
2083 | |
2084 | struct __do_common_type_impl | |
2085 | { | |
2086 | template<typename _Tp, typename _Up> | |
6c5173c0 | 2087 | static __success_type<typename decay<decltype |
fe4e4e3b | 2088 | (true ? std::declval<_Tp>() |
6c5173c0 | 2089 | : std::declval<_Up>())>::type> _S_test(int); |
b3618b71 DK |
2090 | |
2091 | template<typename, typename> | |
2092 | static __failure_type _S_test(...); | |
2093 | }; | |
2094 | ||
2095 | template<typename _Tp, typename _Up> | |
2096 | struct __common_type_impl | |
2097 | : private __do_common_type_impl | |
2098 | { | |
2099 | typedef decltype(_S_test<_Tp, _Up>(0)) type; | |
2100 | }; | |
2101 | ||
2102 | struct __do_member_type_wrapper | |
2103 | { | |
2104 | template<typename _Tp> | |
2105 | static __success_type<typename _Tp::type> _S_test(int); | |
2106 | ||
2107 | template<typename> | |
2108 | static __failure_type _S_test(...); | |
2109 | }; | |
2110 | ||
2111 | template<typename _Tp> | |
2112 | struct __member_type_wrapper | |
2113 | : private __do_member_type_wrapper | |
2114 | { | |
2115 | typedef decltype(_S_test<_Tp>(0)) type; | |
2116 | }; | |
2117 | ||
2118 | template<typename _CTp, typename... _Args> | |
2119 | struct __expanded_common_type_wrapper | |
2120 | { | |
2121 | typedef common_type<typename _CTp::type, _Args...> type; | |
2122 | }; | |
2123 | ||
2124 | template<typename... _Args> | |
2125 | struct __expanded_common_type_wrapper<__failure_type, _Args...> | |
2126 | { typedef __failure_type type; }; | |
2127 | ||
cfa9a96b CF |
2128 | template<typename _Tp> |
2129 | struct common_type<_Tp> | |
6c5173c0 | 2130 | { typedef typename decay<_Tp>::type type; }; |
cfa9a96b CF |
2131 | |
2132 | template<typename _Tp, typename _Up> | |
7274deff | 2133 | struct common_type<_Tp, _Up> |
b3618b71 DK |
2134 | : public __common_type_impl<_Tp, _Up>::type |
2135 | { }; | |
cfa9a96b CF |
2136 | |
2137 | template<typename _Tp, typename _Up, typename... _Vp> | |
2138 | struct common_type<_Tp, _Up, _Vp...> | |
b3618b71 DK |
2139 | : public __expanded_common_type_wrapper<typename __member_type_wrapper< |
2140 | common_type<_Tp, _Up>>::type, _Vp...>::type | |
2141 | { }; | |
7274deff | 2142 | |
13901e4b | 2143 | /// The underlying type of an enum. |
a47407f6 PC |
2144 | template<typename _Tp> |
2145 | struct underlying_type | |
2146 | { | |
2147 | typedef __underlying_type(_Tp) type; | |
2148 | }; | |
123c516a | 2149 | |
7274deff PC |
2150 | template<typename _Tp> |
2151 | struct __declval_protector | |
2152 | { | |
2153 | static const bool __stop = false; | |
7274deff PC |
2154 | }; |
2155 | ||
2156 | template<typename _Tp> | |
ec26ff5a | 2157 | auto declval() noexcept -> decltype(__declval<_Tp>(0)) |
7274deff PC |
2158 | { |
2159 | static_assert(__declval_protector<_Tp>::__stop, | |
2160 | "declval() must not be used!"); | |
ec26ff5a | 2161 | return __declval<_Tp>(0); |
7274deff | 2162 | } |
1041daba | 2163 | |
6791489e JW |
2164 | // __remove_cvref_t (std::remove_cvref_t for C++11). |
2165 | template<typename _Tp> | |
2166 | using __remove_cvref_t | |
2167 | = typename remove_cv<typename remove_reference<_Tp>::type>::type; | |
2168 | ||
be7f7822 JW |
2169 | /// result_of |
2170 | template<typename _Signature> | |
2171 | class result_of; | |
2172 | ||
c0ffa2ba | 2173 | // Sfinae-friendly result_of implementation: |
83ddb39f | 2174 | |
a15f7cb8 ESR |
2175 | #define __cpp_lib_result_of_sfinae 201210 |
2176 | ||
93e95400 JW |
2177 | struct __invoke_memfun_ref { }; |
2178 | struct __invoke_memfun_deref { }; | |
2179 | struct __invoke_memobj_ref { }; | |
2180 | struct __invoke_memobj_deref { }; | |
2181 | struct __invoke_other { }; | |
2182 | ||
2183 | // Associate a tag type with a specialization of __success_type. | |
2184 | template<typename _Tp, typename _Tag> | |
2185 | struct __result_of_success : __success_type<_Tp> | |
2186 | { using __invoke_type = _Tag; }; | |
2187 | ||
83ddb39f DK |
2188 | // [func.require] paragraph 1 bullet 1: |
2189 | struct __result_of_memfun_ref_impl | |
2190 | { | |
2191 | template<typename _Fp, typename _Tp1, typename... _Args> | |
93e95400 | 2192 | static __result_of_success<decltype( |
83ddb39f | 2193 | (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...) |
93e95400 | 2194 | ), __invoke_memfun_ref> _S_test(int); |
83ddb39f DK |
2195 | |
2196 | template<typename...> | |
2197 | static __failure_type _S_test(...); | |
2198 | }; | |
2199 | ||
2200 | template<typename _MemPtr, typename _Arg, typename... _Args> | |
2201 | struct __result_of_memfun_ref | |
2202 | : private __result_of_memfun_ref_impl | |
2203 | { | |
2204 | typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; | |
2205 | }; | |
2206 | ||
2207 | // [func.require] paragraph 1 bullet 2: | |
2208 | struct __result_of_memfun_deref_impl | |
2209 | { | |
2210 | template<typename _Fp, typename _Tp1, typename... _Args> | |
93e95400 | 2211 | static __result_of_success<decltype( |
83ddb39f | 2212 | ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...) |
93e95400 | 2213 | ), __invoke_memfun_deref> _S_test(int); |
83ddb39f DK |
2214 | |
2215 | template<typename...> | |
2216 | static __failure_type _S_test(...); | |
2217 | }; | |
2218 | ||
2219 | template<typename _MemPtr, typename _Arg, typename... _Args> | |
2220 | struct __result_of_memfun_deref | |
2221 | : private __result_of_memfun_deref_impl | |
2222 | { | |
2223 | typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; | |
2224 | }; | |
2225 | ||
2226 | // [func.require] paragraph 1 bullet 3: | |
2227 | struct __result_of_memobj_ref_impl | |
2228 | { | |
2229 | template<typename _Fp, typename _Tp1> | |
93e95400 | 2230 | static __result_of_success<decltype( |
83ddb39f | 2231 | std::declval<_Tp1>().*std::declval<_Fp>() |
93e95400 | 2232 | ), __invoke_memobj_ref> _S_test(int); |
83ddb39f DK |
2233 | |
2234 | template<typename, typename> | |
2235 | static __failure_type _S_test(...); | |
2236 | }; | |
2237 | ||
2238 | template<typename _MemPtr, typename _Arg> | |
2239 | struct __result_of_memobj_ref | |
2240 | : private __result_of_memobj_ref_impl | |
2241 | { | |
2242 | typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; | |
2243 | }; | |
2244 | ||
2245 | // [func.require] paragraph 1 bullet 4: | |
2246 | struct __result_of_memobj_deref_impl | |
2247 | { | |
2248 | template<typename _Fp, typename _Tp1> | |
93e95400 | 2249 | static __result_of_success<decltype( |
83ddb39f | 2250 | (*std::declval<_Tp1>()).*std::declval<_Fp>() |
93e95400 | 2251 | ), __invoke_memobj_deref> _S_test(int); |
83ddb39f DK |
2252 | |
2253 | template<typename, typename> | |
2254 | static __failure_type _S_test(...); | |
2255 | }; | |
2256 | ||
be7f7822 | 2257 | template<typename _MemPtr, typename _Arg> |
83ddb39f DK |
2258 | struct __result_of_memobj_deref |
2259 | : private __result_of_memobj_deref_impl | |
2260 | { | |
2261 | typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; | |
2262 | }; | |
2263 | ||
2264 | template<typename _MemPtr, typename _Arg> | |
2265 | struct __result_of_memobj; | |
be7f7822 JW |
2266 | |
2267 | template<typename _Res, typename _Class, typename _Arg> | |
83ddb39f | 2268 | struct __result_of_memobj<_Res _Class::*, _Arg> |
be7f7822 | 2269 | { |
6791489e | 2270 | typedef __remove_cvref_t<_Arg> _Argval; |
83ddb39f DK |
2271 | typedef _Res _Class::* _MemPtr; |
2272 | typedef typename conditional<__or_<is_same<_Argval, _Class>, | |
2273 | is_base_of<_Class, _Argval>>::value, | |
2274 | __result_of_memobj_ref<_MemPtr, _Arg>, | |
2275 | __result_of_memobj_deref<_MemPtr, _Arg> | |
2276 | >::type::type type; | |
be7f7822 JW |
2277 | }; |
2278 | ||
83ddb39f DK |
2279 | template<typename _MemPtr, typename _Arg, typename... _Args> |
2280 | struct __result_of_memfun; | |
be7f7822 JW |
2281 | |
2282 | template<typename _Res, typename _Class, typename _Arg, typename... _Args> | |
83ddb39f | 2283 | struct __result_of_memfun<_Res _Class::*, _Arg, _Args...> |
be7f7822 | 2284 | { |
6791489e | 2285 | typedef __remove_cvref_t<_Arg> _Argval; |
83ddb39f DK |
2286 | typedef _Res _Class::* _MemPtr; |
2287 | typedef typename conditional<__or_<is_same<_Argval, _Class>, | |
2288 | is_base_of<_Class, _Argval>>::value, | |
2289 | __result_of_memfun_ref<_MemPtr, _Arg, _Args...>, | |
2290 | __result_of_memfun_deref<_MemPtr, _Arg, _Args...> | |
2291 | >::type::type type; | |
be7f7822 JW |
2292 | }; |
2293 | ||
93e95400 JW |
2294 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
2295 | // 2219. INVOKE-ing a pointer to member with a reference_wrapper | |
2296 | // as the object expression | |
93e95400 | 2297 | |
7dcc645c JW |
2298 | // Used by result_of, invoke etc. to unwrap a reference_wrapper. |
2299 | template<typename _Tp, typename _Up = typename decay<_Tp>::type> | |
2300 | struct __inv_unwrap | |
2301 | { | |
2302 | using type = _Tp; | |
2303 | }; | |
f3d7dd52 | 2304 | |
7dcc645c JW |
2305 | template<typename _Tp, typename _Up> |
2306 | struct __inv_unwrap<_Tp, reference_wrapper<_Up>> | |
2307 | { | |
2308 | using type = _Up&; | |
2309 | }; | |
93e95400 | 2310 | |
be7f7822 | 2311 | template<bool, bool, typename _Functor, typename... _ArgTypes> |
83ddb39f | 2312 | struct __result_of_impl |
be7f7822 | 2313 | { |
83ddb39f | 2314 | typedef __failure_type type; |
be7f7822 JW |
2315 | }; |
2316 | ||
2317 | template<typename _MemPtr, typename _Arg> | |
83ddb39f | 2318 | struct __result_of_impl<true, false, _MemPtr, _Arg> |
7dcc645c JW |
2319 | : public __result_of_memobj<typename decay<_MemPtr>::type, |
2320 | typename __inv_unwrap<_Arg>::type> | |
c4db9a77 | 2321 | { }; |
be7f7822 | 2322 | |
83ddb39f DK |
2323 | template<typename _MemPtr, typename _Arg, typename... _Args> |
2324 | struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...> | |
7dcc645c JW |
2325 | : public __result_of_memfun<typename decay<_MemPtr>::type, |
2326 | typename __inv_unwrap<_Arg>::type, _Args...> | |
c4db9a77 | 2327 | { }; |
be7f7822 | 2328 | |
83ddb39f DK |
2329 | // [func.require] paragraph 1 bullet 5: |
2330 | struct __result_of_other_impl | |
2331 | { | |
2332 | template<typename _Fn, typename... _Args> | |
93e95400 | 2333 | static __result_of_success<decltype( |
83ddb39f | 2334 | std::declval<_Fn>()(std::declval<_Args>()...) |
93e95400 | 2335 | ), __invoke_other> _S_test(int); |
83ddb39f DK |
2336 | |
2337 | template<typename...> | |
2338 | static __failure_type _S_test(...); | |
2339 | }; | |
2340 | ||
be7f7822 | 2341 | template<typename _Functor, typename... _ArgTypes> |
83ddb39f DK |
2342 | struct __result_of_impl<false, false, _Functor, _ArgTypes...> |
2343 | : private __result_of_other_impl | |
be7f7822 | 2344 | { |
83ddb39f | 2345 | typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type; |
be7f7822 JW |
2346 | }; |
2347 | ||
7dcc645c | 2348 | // __invoke_result (std::invoke_result for C++11) |
83ddb39f | 2349 | template<typename _Functor, typename... _ArgTypes> |
7dcc645c | 2350 | struct __invoke_result |
83ddb39f DK |
2351 | : public __result_of_impl< |
2352 | is_member_object_pointer< | |
2353 | typename remove_reference<_Functor>::type | |
2354 | >::value, | |
2355 | is_member_function_pointer< | |
2356 | typename remove_reference<_Functor>::type | |
2357 | >::value, | |
7dcc645c | 2358 | _Functor, _ArgTypes... |
83ddb39f DK |
2359 | >::type |
2360 | { }; | |
c0ffa2ba | 2361 | |
7dcc645c JW |
2362 | template<typename _Functor, typename... _ArgTypes> |
2363 | struct result_of<_Functor(_ArgTypes...)> | |
2364 | : public __invoke_result<_Functor, _ArgTypes...> | |
2365 | { }; | |
2366 | ||
e112d53a | 2367 | #if __cplusplus >= 201402L |
4457e88c JW |
2368 | /// Alias template for aligned_storage |
2369 | template<size_t _Len, size_t _Align = | |
2370 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | |
2371 | using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; | |
2372 | ||
d3718027 RS |
2373 | template <size_t _Len, typename... _Types> |
2374 | using aligned_union_t = typename aligned_union<_Len, _Types...>::type; | |
2375 | ||
4457e88c JW |
2376 | /// Alias template for decay |
2377 | template<typename _Tp> | |
2378 | using decay_t = typename decay<_Tp>::type; | |
2379 | ||
2380 | /// Alias template for enable_if | |
2381 | template<bool _Cond, typename _Tp = void> | |
2382 | using enable_if_t = typename enable_if<_Cond, _Tp>::type; | |
2383 | ||
2384 | /// Alias template for conditional | |
2385 | template<bool _Cond, typename _Iftrue, typename _Iffalse> | |
2386 | using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type; | |
2387 | ||
2388 | /// Alias template for common_type | |
2389 | template<typename... _Tp> | |
2390 | using common_type_t = typename common_type<_Tp...>::type; | |
2391 | ||
2392 | /// Alias template for underlying_type | |
2393 | template<typename _Tp> | |
2394 | using underlying_type_t = typename underlying_type<_Tp>::type; | |
2395 | ||
2396 | /// Alias template for result_of | |
2397 | template<typename _Tp> | |
2398 | using result_of_t = typename result_of<_Tp>::type; | |
e112d53a JW |
2399 | #endif // C++14 |
2400 | ||
2401 | // __enable_if_t (std::enable_if_t for C++11) | |
2402 | template<bool _Cond, typename _Tp = void> | |
2403 | using __enable_if_t = typename enable_if<_Cond, _Tp>::type; | |
4457e88c | 2404 | |
e112d53a | 2405 | // __void_t (std::void_t for C++11) |
847e9cf8 JW |
2406 | template<typename...> using __void_t = void; |
2407 | ||
e112d53a | 2408 | #if __cplusplus >= 201703L || !defined(__STRICT_ANSI__) // c++17 or gnu++11 |
bd1eb5e0 JW |
2409 | #define __cpp_lib_void_t 201411 |
2410 | /// A metafunction that always yields void, used for detecting valid types. | |
2411 | template<typename...> using void_t = void; | |
2412 | #endif | |
2413 | ||
6af6bef4 JW |
2414 | /// Implementation of the detection idiom (negative case). |
2415 | template<typename _Default, typename _AlwaysVoid, | |
2416 | template<typename...> class _Op, typename... _Args> | |
2417 | struct __detector | |
2418 | { | |
2419 | using value_t = false_type; | |
2420 | using type = _Default; | |
2421 | }; | |
2422 | ||
2423 | /// Implementation of the detection idiom (positive case). | |
2424 | template<typename _Default, template<typename...> class _Op, | |
2425 | typename... _Args> | |
2426 | struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...> | |
2427 | { | |
2428 | using value_t = true_type; | |
2429 | using type = _Op<_Args...>; | |
2430 | }; | |
2431 | ||
2432 | // Detect whether _Op<_Args...> is a valid type, use _Default if not. | |
2433 | template<typename _Default, template<typename...> class _Op, | |
2434 | typename... _Args> | |
2435 | using __detected_or = __detector<_Default, void, _Op, _Args...>; | |
2436 | ||
2437 | // _Op<_Args...> if that is a valid type, otherwise _Default. | |
2438 | template<typename _Default, template<typename...> class _Op, | |
2439 | typename... _Args> | |
2440 | using __detected_or_t | |
2441 | = typename __detected_or<_Default, _Op, _Args...>::type; | |
2442 | ||
c0ffa2ba | 2443 | /// @} group metaprogramming |
847e9cf8 | 2444 | |
033b71ce PC |
2445 | /** |
2446 | * Use SFINAE to determine if the type _Tp has a publicly-accessible | |
2447 | * member type _NTYPE. | |
2448 | */ | |
82b12c4b | 2449 | #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \ |
847e9cf8 | 2450 | template<typename _Tp, typename = __void_t<>> \ |
82b12c4b | 2451 | struct __has_##_NTYPE \ |
847e9cf8 JW |
2452 | : false_type \ |
2453 | { }; \ | |
2454 | template<typename _Tp> \ | |
2455 | struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \ | |
2456 | : true_type \ | |
033b71ce PC |
2457 | { }; |
2458 | ||
26b5ace7 DK |
2459 | template <typename _Tp> |
2460 | struct __is_swappable; | |
ddb63209 | 2461 | |
26b5ace7 DK |
2462 | template <typename _Tp> |
2463 | struct __is_nothrow_swappable; | |
ddb63209 | 2464 | |
a2863bde VV |
2465 | template<typename... _Elements> |
2466 | class tuple; | |
2467 | ||
2468 | template<typename> | |
2469 | struct __is_tuple_like_impl : false_type | |
2470 | { }; | |
2471 | ||
2472 | template<typename... _Tps> | |
2473 | struct __is_tuple_like_impl<tuple<_Tps...>> : true_type | |
2474 | { }; | |
2475 | ||
2476 | // Internal type trait that allows us to sfinae-protect tuple_cat. | |
2477 | template<typename _Tp> | |
2478 | struct __is_tuple_like | |
6791489e | 2479 | : public __is_tuple_like_impl<__remove_cvref_t<_Tp>>::type |
a2863bde VV |
2480 | { }; |
2481 | ||
ddb63209 VV |
2482 | template<typename _Tp> |
2483 | inline | |
a2863bde VV |
2484 | typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>, |
2485 | is_move_constructible<_Tp>, | |
ddb63209 VV |
2486 | is_move_assignable<_Tp>>::value>::type |
2487 | swap(_Tp&, _Tp&) | |
2488 | noexcept(__and_<is_nothrow_move_constructible<_Tp>, | |
2489 | is_nothrow_move_assignable<_Tp>>::value); | |
2490 | ||
2491 | template<typename _Tp, size_t _Nm> | |
2492 | inline | |
26b5ace7 | 2493 | typename enable_if<__is_swappable<_Tp>::value>::type |
ddb63209 | 2494 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) |
26b5ace7 | 2495 | noexcept(__is_nothrow_swappable<_Tp>::value); |
ddb63209 | 2496 | |
26b5ace7 | 2497 | namespace __swappable_details { |
ddb63209 VV |
2498 | using std::swap; |
2499 | ||
26b5ace7 DK |
2500 | struct __do_is_swappable_impl |
2501 | { | |
2502 | template<typename _Tp, typename | |
2503 | = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))> | |
2504 | static true_type __test(int); | |
2505 | ||
2506 | template<typename> | |
2507 | static false_type __test(...); | |
2508 | }; | |
2509 | ||
2510 | struct __do_is_nothrow_swappable_impl | |
2511 | { | |
2512 | template<typename _Tp> | |
2513 | static __bool_constant< | |
2514 | noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>())) | |
2515 | > __test(int); | |
2516 | ||
2517 | template<typename> | |
2518 | static false_type __test(...); | |
2519 | }; | |
2520 | ||
6b9539e2 | 2521 | } // namespace __swappable_details |
ddb63209 | 2522 | |
26b5ace7 DK |
2523 | template<typename _Tp> |
2524 | struct __is_swappable_impl | |
2525 | : public __swappable_details::__do_is_swappable_impl | |
2526 | { | |
2527 | typedef decltype(__test<_Tp>(0)) type; | |
2528 | }; | |
2529 | ||
2530 | template<typename _Tp> | |
ddb63209 | 2531 | struct __is_nothrow_swappable_impl |
26b5ace7 DK |
2532 | : public __swappable_details::__do_is_nothrow_swappable_impl |
2533 | { | |
2534 | typedef decltype(__test<_Tp>(0)) type; | |
2535 | }; | |
ddb63209 | 2536 | |
26b5ace7 DK |
2537 | template<typename _Tp> |
2538 | struct __is_swappable | |
2539 | : public __is_swappable_impl<_Tp>::type | |
ddb63209 VV |
2540 | { }; |
2541 | ||
26b5ace7 | 2542 | template<typename _Tp> |
ddb63209 | 2543 | struct __is_nothrow_swappable |
26b5ace7 | 2544 | : public __is_nothrow_swappable_impl<_Tp>::type |
ddb63209 VV |
2545 | { }; |
2546 | ||
6b9539e2 DK |
2547 | #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 |
2548 | #define __cpp_lib_is_swappable 201603 | |
2549 | /// Metafunctions used for detecting swappable types: p0185r1 | |
2550 | ||
2551 | /// is_swappable | |
2552 | template<typename _Tp> | |
2553 | struct is_swappable | |
2554 | : public __is_swappable_impl<_Tp>::type | |
2555 | { }; | |
2556 | ||
2557 | /// is_nothrow_swappable | |
2558 | template<typename _Tp> | |
2559 | struct is_nothrow_swappable | |
2560 | : public __is_nothrow_swappable_impl<_Tp>::type | |
2561 | { }; | |
2562 | ||
2563 | #if __cplusplus >= 201402L | |
2564 | /// is_swappable_v | |
2565 | template<typename _Tp> | |
288695f7 DK |
2566 | _GLIBCXX17_INLINE constexpr bool is_swappable_v = |
2567 | is_swappable<_Tp>::value; | |
6b9539e2 DK |
2568 | |
2569 | /// is_nothrow_swappable_v | |
2570 | template<typename _Tp> | |
288695f7 DK |
2571 | _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v = |
2572 | is_nothrow_swappable<_Tp>::value; | |
6b9539e2 DK |
2573 | #endif // __cplusplus >= 201402L |
2574 | ||
2575 | namespace __swappable_with_details { | |
2576 | using std::swap; | |
2577 | ||
2578 | struct __do_is_swappable_with_impl | |
2579 | { | |
2580 | template<typename _Tp, typename _Up, typename | |
2581 | = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())), | |
2582 | typename | |
2583 | = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))> | |
2584 | static true_type __test(int); | |
2585 | ||
2586 | template<typename, typename> | |
2587 | static false_type __test(...); | |
2588 | }; | |
2589 | ||
2590 | struct __do_is_nothrow_swappable_with_impl | |
2591 | { | |
2592 | template<typename _Tp, typename _Up> | |
2593 | static __bool_constant< | |
2594 | noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) | |
2595 | && | |
2596 | noexcept(swap(std::declval<_Up>(), std::declval<_Tp>())) | |
2597 | > __test(int); | |
2598 | ||
2599 | template<typename, typename> | |
2600 | static false_type __test(...); | |
2601 | }; | |
2602 | ||
2603 | } // namespace __swappable_with_details | |
2604 | ||
2605 | template<typename _Tp, typename _Up> | |
2606 | struct __is_swappable_with_impl | |
2607 | : public __swappable_with_details::__do_is_swappable_with_impl | |
2608 | { | |
2609 | typedef decltype(__test<_Tp, _Up>(0)) type; | |
2610 | }; | |
2611 | ||
2612 | // Optimization for the homogenous lvalue case, not required: | |
2613 | template<typename _Tp> | |
2614 | struct __is_swappable_with_impl<_Tp&, _Tp&> | |
2615 | : public __swappable_details::__do_is_swappable_impl | |
2616 | { | |
2617 | typedef decltype(__test<_Tp&>(0)) type; | |
2618 | }; | |
2619 | ||
2620 | template<typename _Tp, typename _Up> | |
2621 | struct __is_nothrow_swappable_with_impl | |
2622 | : public __swappable_with_details::__do_is_nothrow_swappable_with_impl | |
2623 | { | |
2624 | typedef decltype(__test<_Tp, _Up>(0)) type; | |
2625 | }; | |
2626 | ||
2627 | // Optimization for the homogenous lvalue case, not required: | |
2628 | template<typename _Tp> | |
2629 | struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&> | |
2630 | : public __swappable_details::__do_is_nothrow_swappable_impl | |
2631 | { | |
2632 | typedef decltype(__test<_Tp&>(0)) type; | |
2633 | }; | |
2634 | ||
2635 | /// is_swappable_with | |
2636 | template<typename _Tp, typename _Up> | |
2637 | struct is_swappable_with | |
2638 | : public __is_swappable_with_impl<_Tp, _Up>::type | |
2639 | { }; | |
2640 | ||
2641 | /// is_nothrow_swappable_with | |
2642 | template<typename _Tp, typename _Up> | |
2643 | struct is_nothrow_swappable_with | |
2644 | : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type | |
2645 | { }; | |
2646 | ||
2647 | #if __cplusplus >= 201402L | |
2648 | /// is_swappable_with_v | |
2649 | template<typename _Tp, typename _Up> | |
288695f7 DK |
2650 | _GLIBCXX17_INLINE constexpr bool is_swappable_with_v = |
2651 | is_swappable_with<_Tp, _Up>::value; | |
6b9539e2 DK |
2652 | |
2653 | /// is_nothrow_swappable_with_v | |
2654 | template<typename _Tp, typename _Up> | |
288695f7 | 2655 | _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v = |
6b9539e2 DK |
2656 | is_nothrow_swappable_with<_Tp, _Up>::value; |
2657 | #endif // __cplusplus >= 201402L | |
137422c8 | 2658 | |
42183d03 JW |
2659 | #endif// c++1z or gnu++11 |
2660 | ||
7dcc645c | 2661 | // __is_invocable (std::is_invocable for C++11) |
42183d03 | 2662 | |
7dcc645c JW |
2663 | template<typename _Result, typename _Ret, typename = void> |
2664 | struct __is_invocable_impl : false_type { }; | |
42183d03 JW |
2665 | |
2666 | template<typename _Result, typename _Ret> | |
7dcc645c | 2667 | struct __is_invocable_impl<_Result, _Ret, __void_t<typename _Result::type>> |
91d01b33 | 2668 | : __or_<is_void<_Ret>, is_convertible<typename _Result::type, _Ret>>::type |
42183d03 JW |
2669 | { }; |
2670 | ||
7dcc645c JW |
2671 | template<typename _Fn, typename... _ArgTypes> |
2672 | struct __is_invocable | |
2673 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type | |
42183d03 JW |
2674 | { }; |
2675 | ||
42183d03 JW |
2676 | template<typename _Fn, typename _Tp, typename... _Args> |
2677 | constexpr bool __call_is_nt(__invoke_memfun_ref) | |
2678 | { | |
2679 | using _Up = typename __inv_unwrap<_Tp>::type; | |
2680 | return noexcept((std::declval<_Up>().*std::declval<_Fn>())( | |
2681 | std::declval<_Args>()...)); | |
2682 | } | |
2683 | ||
2684 | template<typename _Fn, typename _Tp, typename... _Args> | |
2685 | constexpr bool __call_is_nt(__invoke_memfun_deref) | |
2686 | { | |
2687 | return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())( | |
2688 | std::declval<_Args>()...)); | |
2689 | } | |
2690 | ||
2691 | template<typename _Fn, typename _Tp> | |
2692 | constexpr bool __call_is_nt(__invoke_memobj_ref) | |
2693 | { | |
2694 | using _Up = typename __inv_unwrap<_Tp>::type; | |
2695 | return noexcept(std::declval<_Up>().*std::declval<_Fn>()); | |
2696 | } | |
2697 | ||
2698 | template<typename _Fn, typename _Tp> | |
2699 | constexpr bool __call_is_nt(__invoke_memobj_deref) | |
2700 | { | |
2701 | return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>()); | |
2702 | } | |
2703 | ||
2704 | template<typename _Fn, typename... _Args> | |
2705 | constexpr bool __call_is_nt(__invoke_other) | |
2706 | { | |
2707 | return noexcept(std::declval<_Fn>()(std::declval<_Args>()...)); | |
2708 | } | |
2709 | ||
7dcc645c | 2710 | template<typename _Result, typename _Fn, typename... _Args> |
42183d03 JW |
2711 | struct __call_is_nothrow |
2712 | : __bool_constant< | |
7dcc645c JW |
2713 | std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{}) |
2714 | > | |
42183d03 JW |
2715 | { }; |
2716 | ||
7dcc645c JW |
2717 | template<typename _Fn, typename... _Args> |
2718 | using __call_is_nothrow_ | |
2719 | = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>; | |
42183d03 | 2720 | |
7dcc645c JW |
2721 | // __is_nothrow_invocable (std::is_nothrow_invocable for C++11) |
2722 | template<typename _Fn, typename... _Args> | |
2723 | struct __is_nothrow_invocable | |
2724 | : __and_<__is_invocable<_Fn, _Args...>, | |
2725 | __call_is_nothrow_<_Fn, _Args...>>::type | |
42183d03 JW |
2726 | { }; |
2727 | ||
f524d5b3 VV |
2728 | struct __nonesuch { |
2729 | __nonesuch() = delete; | |
2730 | ~__nonesuch() = delete; | |
2731 | __nonesuch(__nonesuch const&) = delete; | |
2732 | void operator=(__nonesuch const&) = delete; | |
2733 | }; | |
2734 | ||
e641ee43 | 2735 | #if __cplusplus >= 201703L |
7dcc645c JW |
2736 | # define __cpp_lib_is_invocable 201703 |
2737 | ||
2738 | /// std::invoke_result | |
2739 | template<typename _Functor, typename... _ArgTypes> | |
2740 | struct invoke_result | |
2741 | : public __invoke_result<_Functor, _ArgTypes...> | |
2742 | { }; | |
2743 | ||
2744 | /// std::invoke_result_t | |
2745 | template<typename _Fn, typename... _Args> | |
2746 | using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; | |
42183d03 | 2747 | |
7dcc645c JW |
2748 | /// std::is_invocable |
2749 | template<typename _Fn, typename... _ArgTypes> | |
2750 | struct is_invocable | |
2751 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type | |
2752 | { }; | |
42183d03 | 2753 | |
7dcc645c JW |
2754 | /// std::is_invocable_r |
2755 | template<typename _Ret, typename _Fn, typename... _ArgTypes> | |
2756 | struct is_invocable_r | |
2757 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type | |
42183d03 JW |
2758 | { }; |
2759 | ||
7dcc645c JW |
2760 | /// std::is_nothrow_invocable |
2761 | template<typename _Fn, typename... _ArgTypes> | |
2762 | struct is_nothrow_invocable | |
2763 | : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>, | |
2764 | __call_is_nothrow_<_Fn, _ArgTypes...>>::type | |
2765 | { }; | |
42183d03 | 2766 | |
c4b06e7f JW |
2767 | template<typename _Result, typename _Ret, typename = void> |
2768 | struct __is_nt_invocable_impl : false_type { }; | |
2769 | ||
2770 | template<typename _Result, typename _Ret> | |
2771 | struct __is_nt_invocable_impl<_Result, _Ret, | |
2772 | __void_t<typename _Result::type>> | |
91d01b33 JW |
2773 | : __or_<is_void<_Ret>, |
2774 | __and_<is_convertible<typename _Result::type, _Ret>, | |
2775 | is_nothrow_constructible<_Ret, typename _Result::type>>> | |
c4b06e7f JW |
2776 | { }; |
2777 | ||
7dcc645c JW |
2778 | /// std::is_nothrow_invocable_r |
2779 | template<typename _Ret, typename _Fn, typename... _ArgTypes> | |
2780 | struct is_nothrow_invocable_r | |
c4b06e7f | 2781 | : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>, |
7dcc645c | 2782 | __call_is_nothrow_<_Fn, _ArgTypes...>>::type |
42183d03 JW |
2783 | { }; |
2784 | ||
7dcc645c JW |
2785 | /// std::is_invocable_v |
2786 | template<typename _Fn, typename... _Args> | |
2787 | inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; | |
42183d03 | 2788 | |
7dcc645c JW |
2789 | /// std::is_nothrow_invocable_v |
2790 | template<typename _Fn, typename... _Args> | |
2791 | inline constexpr bool is_nothrow_invocable_v | |
2792 | = is_nothrow_invocable<_Fn, _Args...>::value; | |
42183d03 | 2793 | |
7dcc645c JW |
2794 | /// std::is_invocable_r_v |
2795 | template<typename _Fn, typename... _Args> | |
2796 | inline constexpr bool is_invocable_r_v | |
2797 | = is_invocable_r<_Fn, _Args...>::value; | |
2798 | ||
2799 | /// std::is_nothrow_invocable_r_v | |
2800 | template<typename _Fn, typename... _Args> | |
2801 | inline constexpr bool is_nothrow_invocable_r_v | |
2802 | = is_nothrow_invocable_r<_Fn, _Args...>::value; | |
2803 | #endif // C++17 | |
42183d03 | 2804 | |
e641ee43 | 2805 | #if __cplusplus >= 201703L |
068c8ac1 | 2806 | # define __cpp_lib_type_trait_variable_templates 201510L |
137422c8 | 2807 | template <typename _Tp> |
288695f7 | 2808 | inline constexpr bool is_void_v = is_void<_Tp>::value; |
137422c8 | 2809 | template <typename _Tp> |
288695f7 | 2810 | inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; |
137422c8 | 2811 | template <typename _Tp> |
288695f7 | 2812 | inline constexpr bool is_integral_v = is_integral<_Tp>::value; |
137422c8 | 2813 | template <typename _Tp> |
288695f7 | 2814 | inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; |
137422c8 | 2815 | template <typename _Tp> |
288695f7 | 2816 | inline constexpr bool is_array_v = is_array<_Tp>::value; |
137422c8 | 2817 | template <typename _Tp> |
288695f7 | 2818 | inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; |
137422c8 | 2819 | template <typename _Tp> |
288695f7 DK |
2820 | inline constexpr bool is_lvalue_reference_v = |
2821 | is_lvalue_reference<_Tp>::value; | |
137422c8 | 2822 | template <typename _Tp> |
288695f7 DK |
2823 | inline constexpr bool is_rvalue_reference_v = |
2824 | is_rvalue_reference<_Tp>::value; | |
137422c8 | 2825 | template <typename _Tp> |
288695f7 | 2826 | inline constexpr bool is_member_object_pointer_v = |
137422c8 VV |
2827 | is_member_object_pointer<_Tp>::value; |
2828 | template <typename _Tp> | |
288695f7 | 2829 | inline constexpr bool is_member_function_pointer_v = |
137422c8 VV |
2830 | is_member_function_pointer<_Tp>::value; |
2831 | template <typename _Tp> | |
288695f7 | 2832 | inline constexpr bool is_enum_v = is_enum<_Tp>::value; |
137422c8 | 2833 | template <typename _Tp> |
288695f7 | 2834 | inline constexpr bool is_union_v = is_union<_Tp>::value; |
137422c8 | 2835 | template <typename _Tp> |
288695f7 | 2836 | inline constexpr bool is_class_v = is_class<_Tp>::value; |
137422c8 | 2837 | template <typename _Tp> |
288695f7 | 2838 | inline constexpr bool is_function_v = is_function<_Tp>::value; |
137422c8 | 2839 | template <typename _Tp> |
288695f7 | 2840 | inline constexpr bool is_reference_v = is_reference<_Tp>::value; |
137422c8 | 2841 | template <typename _Tp> |
288695f7 | 2842 | inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; |
137422c8 | 2843 | template <typename _Tp> |
288695f7 | 2844 | inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; |
137422c8 | 2845 | template <typename _Tp> |
288695f7 | 2846 | inline constexpr bool is_object_v = is_object<_Tp>::value; |
137422c8 | 2847 | template <typename _Tp> |
288695f7 | 2848 | inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; |
137422c8 | 2849 | template <typename _Tp> |
288695f7 | 2850 | inline constexpr bool is_compound_v = is_compound<_Tp>::value; |
137422c8 | 2851 | template <typename _Tp> |
288695f7 | 2852 | inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; |
137422c8 | 2853 | template <typename _Tp> |
288695f7 | 2854 | inline constexpr bool is_const_v = is_const<_Tp>::value; |
137422c8 | 2855 | template <typename _Tp> |
288695f7 | 2856 | inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; |
137422c8 | 2857 | template <typename _Tp> |
288695f7 | 2858 | inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; |
137422c8 | 2859 | template <typename _Tp> |
288695f7 DK |
2860 | inline constexpr bool is_trivially_copyable_v = |
2861 | is_trivially_copyable<_Tp>::value; | |
137422c8 | 2862 | template <typename _Tp> |
288695f7 | 2863 | inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; |
137422c8 | 2864 | template <typename _Tp> |
288695f7 | 2865 | inline constexpr bool is_pod_v = is_pod<_Tp>::value; |
137422c8 | 2866 | template <typename _Tp> |
288695f7 | 2867 | inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; |
137422c8 | 2868 | template <typename _Tp> |
288695f7 | 2869 | inline constexpr bool is_empty_v = is_empty<_Tp>::value; |
137422c8 | 2870 | template <typename _Tp> |
288695f7 | 2871 | inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; |
137422c8 | 2872 | template <typename _Tp> |
288695f7 | 2873 | inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; |
137422c8 | 2874 | template <typename _Tp> |
288695f7 | 2875 | inline constexpr bool is_final_v = is_final<_Tp>::value; |
137422c8 | 2876 | template <typename _Tp> |
288695f7 | 2877 | inline constexpr bool is_signed_v = is_signed<_Tp>::value; |
137422c8 | 2878 | template <typename _Tp> |
288695f7 | 2879 | inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; |
137422c8 | 2880 | template <typename _Tp, typename... _Args> |
288695f7 DK |
2881 | inline constexpr bool is_constructible_v = |
2882 | is_constructible<_Tp, _Args...>::value; | |
137422c8 | 2883 | template <typename _Tp> |
288695f7 | 2884 | inline constexpr bool is_default_constructible_v = |
137422c8 VV |
2885 | is_default_constructible<_Tp>::value; |
2886 | template <typename _Tp> | |
288695f7 DK |
2887 | inline constexpr bool is_copy_constructible_v = |
2888 | is_copy_constructible<_Tp>::value; | |
137422c8 | 2889 | template <typename _Tp> |
288695f7 DK |
2890 | inline constexpr bool is_move_constructible_v = |
2891 | is_move_constructible<_Tp>::value; | |
137422c8 | 2892 | template <typename _Tp, typename _Up> |
288695f7 | 2893 | inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value; |
137422c8 | 2894 | template <typename _Tp> |
288695f7 | 2895 | inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; |
137422c8 | 2896 | template <typename _Tp> |
288695f7 | 2897 | inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; |
137422c8 | 2898 | template <typename _Tp> |
288695f7 | 2899 | inline constexpr bool is_destructible_v = is_destructible<_Tp>::value; |
137422c8 | 2900 | template <typename _Tp, typename... _Args> |
288695f7 | 2901 | inline constexpr bool is_trivially_constructible_v = |
137422c8 VV |
2902 | is_trivially_constructible<_Tp, _Args...>::value; |
2903 | template <typename _Tp> | |
288695f7 | 2904 | inline constexpr bool is_trivially_default_constructible_v = |
137422c8 VV |
2905 | is_trivially_default_constructible<_Tp>::value; |
2906 | template <typename _Tp> | |
288695f7 | 2907 | inline constexpr bool is_trivially_copy_constructible_v = |
137422c8 VV |
2908 | is_trivially_copy_constructible<_Tp>::value; |
2909 | template <typename _Tp> | |
288695f7 | 2910 | inline constexpr bool is_trivially_move_constructible_v = |
137422c8 VV |
2911 | is_trivially_move_constructible<_Tp>::value; |
2912 | template <typename _Tp, typename _Up> | |
288695f7 | 2913 | inline constexpr bool is_trivially_assignable_v = |
137422c8 VV |
2914 | is_trivially_assignable<_Tp, _Up>::value; |
2915 | template <typename _Tp> | |
288695f7 | 2916 | inline constexpr bool is_trivially_copy_assignable_v = |
137422c8 VV |
2917 | is_trivially_copy_assignable<_Tp>::value; |
2918 | template <typename _Tp> | |
288695f7 | 2919 | inline constexpr bool is_trivially_move_assignable_v = |
137422c8 VV |
2920 | is_trivially_move_assignable<_Tp>::value; |
2921 | template <typename _Tp> | |
288695f7 | 2922 | inline constexpr bool is_trivially_destructible_v = |
137422c8 VV |
2923 | is_trivially_destructible<_Tp>::value; |
2924 | template <typename _Tp, typename... _Args> | |
288695f7 | 2925 | inline constexpr bool is_nothrow_constructible_v = |
137422c8 VV |
2926 | is_nothrow_constructible<_Tp, _Args...>::value; |
2927 | template <typename _Tp> | |
288695f7 | 2928 | inline constexpr bool is_nothrow_default_constructible_v = |
137422c8 VV |
2929 | is_nothrow_default_constructible<_Tp>::value; |
2930 | template <typename _Tp> | |
288695f7 | 2931 | inline constexpr bool is_nothrow_copy_constructible_v = |
137422c8 VV |
2932 | is_nothrow_copy_constructible<_Tp>::value; |
2933 | template <typename _Tp> | |
288695f7 | 2934 | inline constexpr bool is_nothrow_move_constructible_v = |
137422c8 VV |
2935 | is_nothrow_move_constructible<_Tp>::value; |
2936 | template <typename _Tp, typename _Up> | |
288695f7 | 2937 | inline constexpr bool is_nothrow_assignable_v = |
137422c8 VV |
2938 | is_nothrow_assignable<_Tp, _Up>::value; |
2939 | template <typename _Tp> | |
288695f7 | 2940 | inline constexpr bool is_nothrow_copy_assignable_v = |
137422c8 VV |
2941 | is_nothrow_copy_assignable<_Tp>::value; |
2942 | template <typename _Tp> | |
288695f7 | 2943 | inline constexpr bool is_nothrow_move_assignable_v = |
137422c8 VV |
2944 | is_nothrow_move_assignable<_Tp>::value; |
2945 | template <typename _Tp> | |
288695f7 | 2946 | inline constexpr bool is_nothrow_destructible_v = |
137422c8 VV |
2947 | is_nothrow_destructible<_Tp>::value; |
2948 | template <typename _Tp> | |
288695f7 | 2949 | inline constexpr bool has_virtual_destructor_v = |
137422c8 VV |
2950 | has_virtual_destructor<_Tp>::value; |
2951 | template <typename _Tp> | |
288695f7 | 2952 | inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; |
137422c8 | 2953 | template <typename _Tp> |
288695f7 | 2954 | inline constexpr size_t rank_v = rank<_Tp>::value; |
137422c8 | 2955 | template <typename _Tp, unsigned _Idx = 0> |
288695f7 | 2956 | inline constexpr size_t extent_v = extent<_Tp, _Idx>::value; |
137422c8 | 2957 | template <typename _Tp, typename _Up> |
288695f7 | 2958 | inline constexpr bool is_same_v = is_same<_Tp, _Up>::value; |
137422c8 | 2959 | template <typename _Base, typename _Derived> |
288695f7 | 2960 | inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; |
137422c8 | 2961 | template <typename _From, typename _To> |
288695f7 | 2962 | inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; |
873c7d5a | 2963 | |
2d763763 JW |
2964 | #if __GNUC__ >= 7 |
2965 | # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1 | |
2966 | #elif defined(__is_identifier) | |
2967 | // For non-GNU compilers: | |
2968 | # if ! __is_identifier(__has_unique_object_representations) | |
2969 | # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1 | |
1f5700e9 JW |
2970 | # endif |
2971 | #endif | |
2972 | ||
2d763763 | 2973 | #ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP |
873c7d5a JW |
2974 | # define __cpp_lib_has_unique_object_representations 201606 |
2975 | /// has_unique_object_representations | |
2976 | template<typename _Tp> | |
2977 | struct has_unique_object_representations | |
2978 | : bool_constant<__has_unique_object_representations( | |
2979 | remove_cv_t<remove_all_extents_t<_Tp>> | |
2980 | )> | |
2981 | { }; | |
b0e63d94 JW |
2982 | |
2983 | template<typename _Tp> | |
2984 | inline constexpr bool has_unique_object_representations_v | |
2985 | = has_unique_object_representations<_Tp>::value; | |
1f5700e9 | 2986 | #endif |
2d763763 | 2987 | #undef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP |
873c7d5a | 2988 | |
afa56c17 JW |
2989 | #if __GNUC__ >= 7 |
2990 | # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 | |
2ae804bf | 2991 | #elif defined(__is_identifier) |
afa56c17 | 2992 | // For non-GNU compilers: |
2ae804bf | 2993 | # if ! __is_identifier(__is_aggregate) |
afa56c17 | 2994 | # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 |
e2ac6765 VV |
2995 | # endif |
2996 | #endif | |
2997 | ||
afa56c17 | 2998 | #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE |
e2ac6765 VV |
2999 | #define __cpp_lib_is_aggregate 201703 |
3000 | /// is_aggregate | |
3001 | template<typename _Tp> | |
3002 | struct is_aggregate | |
3003 | : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> { }; | |
3004 | ||
3005 | /// is_aggregate_v | |
3006 | template<typename _Tp> | |
3007 | inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; | |
3008 | #endif | |
afa56c17 | 3009 | #undef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE |
e2ac6765 | 3010 | |
137422c8 | 3011 | #endif // C++17 |
6b9539e2 | 3012 | |
e641ee43 JW |
3013 | #if __cplusplus > 201703L |
3014 | /// Byte order | |
3015 | enum class endian | |
3016 | { | |
3017 | little = __ORDER_LITTLE_ENDIAN__, | |
3018 | big = __ORDER_BIG_ENDIAN__, | |
3019 | native = __BYTE_ORDER__ | |
3020 | }; | |
6791489e JW |
3021 | |
3022 | /// Remove references and cv-qualifiers. | |
3023 | template<typename _Tp> | |
3024 | struct remove_cvref | |
3025 | { | |
3026 | using type = __remove_cvref_t<_Tp>; | |
3027 | }; | |
3028 | ||
3029 | template<typename _Tp> | |
3030 | using remove_cvref_t = __remove_cvref_t<_Tp>; | |
3031 | ||
ee896276 JW |
3032 | /// Identity metafunction. |
3033 | template<typename _Tp> | |
3034 | struct type_identity { using type = _Tp; }; | |
3035 | ||
3036 | template<typename _Tp> | |
3037 | using type_identity_t = typename type_identity<_Tp>::type; | |
3038 | ||
e641ee43 JW |
3039 | #endif // C++2a |
3040 | ||
12ffa228 | 3041 | _GLIBCXX_END_NAMESPACE_VERSION |
c0ffa2ba | 3042 | } // namespace std |
7b50cdef | 3043 | |
734f5023 | 3044 | #endif // C++11 |
57317d2a | 3045 | |
7274deff | 3046 | #endif // _GLIBCXX_TYPE_TRAITS |