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