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