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