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