32#ifndef _CPP_TYPE_TRAITS_H
33#define _CPP_TYPE_TRAITS_H 1
35#pragma GCC system_header
39#if __glibcxx_type_trait_variable_templates
73namespace std _GLIBCXX_VISIBILITY(default)
75_GLIBCXX_BEGIN_NAMESPACE_VERSION
77 struct __true_type { };
78 struct __false_type { };
82 {
typedef __false_type __type; };
85 struct __truth_type<true>
86 {
typedef __true_type __type; };
90 template<
class _Sp,
class _Tp>
93 enum { __value = bool(_Sp::__value) || bool(_Tp::__value) };
94 typedef typename __truth_type<__value>::__type __type;
98 template<
typename,
typename>
101 enum { __value = 0 };
102 typedef __false_type __type;
105 template<
typename _Tp>
106 struct __are_same<_Tp, _Tp>
108 enum { __value = 1 };
109 typedef __true_type __type;
115 template<
typename _Tp>
118 enum { __value = 0 };
119 typedef __false_type __type;
125 struct __is_integer<bool>
127 enum { __value = 1 };
128 typedef __true_type __type;
132 struct __is_integer<char>
134 enum { __value = 1 };
135 typedef __true_type __type;
139 struct __is_integer<signed char>
141 enum { __value = 1 };
142 typedef __true_type __type;
146 struct __is_integer<unsigned char>
148 enum { __value = 1 };
149 typedef __true_type __type;
152# ifdef __WCHAR_TYPE__
154 struct __is_integer<wchar_t>
156 enum { __value = 1 };
157 typedef __true_type __type;
161#ifdef _GLIBCXX_USE_CHAR8_T
163 struct __is_integer<char8_t>
165 enum { __value = 1 };
166 typedef __true_type __type;
170#if __cplusplus >= 201103L
172 struct __is_integer<char16_t>
174 enum { __value = 1 };
175 typedef __true_type __type;
179 struct __is_integer<char32_t>
181 enum { __value = 1 };
182 typedef __true_type __type;
187 struct __is_integer<short>
189 enum { __value = 1 };
190 typedef __true_type __type;
194 struct __is_integer<unsigned short>
196 enum { __value = 1 };
197 typedef __true_type __type;
201 struct __is_integer<int>
203 enum { __value = 1 };
204 typedef __true_type __type;
208 struct __is_integer<unsigned int>
210 enum { __value = 1 };
211 typedef __true_type __type;
215 struct __is_integer<long>
217 enum { __value = 1 };
218 typedef __true_type __type;
222 struct __is_integer<unsigned long>
224 enum { __value = 1 };
225 typedef __true_type __type;
229 struct __is_integer<long long>
231 enum { __value = 1 };
232 typedef __true_type __type;
236 struct __is_integer<unsigned long long>
238 enum { __value = 1 };
239 typedef __true_type __type;
242#define __INT_N(TYPE) \
245 struct __is_integer<TYPE> \
247 enum { __value = 1 }; \
248 typedef __true_type __type; \
252 struct __is_integer<unsigned TYPE> \
254 enum { __value = 1 }; \
255 typedef __true_type __type; \
258#ifdef __GLIBCXX_TYPE_INT_N_0
259__INT_N(__GLIBCXX_TYPE_INT_N_0)
261#ifdef __GLIBCXX_TYPE_INT_N_1
262__INT_N(__GLIBCXX_TYPE_INT_N_1)
264#ifdef __GLIBCXX_TYPE_INT_N_2
265__INT_N(__GLIBCXX_TYPE_INT_N_2)
267#ifdef __GLIBCXX_TYPE_INT_N_3
268__INT_N(__GLIBCXX_TYPE_INT_N_3)
276 template<
typename _Tp>
279 enum { __value = 0 };
280 typedef __false_type __type;
285 struct __is_floating<float>
287 enum { __value = 1 };
288 typedef __true_type __type;
292 struct __is_floating<double>
294 enum { __value = 1 };
295 typedef __true_type __type;
299 struct __is_floating<long double>
301 enum { __value = 1 };
302 typedef __true_type __type;
305#ifdef __STDCPP_FLOAT16_T__
307 struct __is_floating<_Float16>
309 enum { __value = 1 };
310 typedef __true_type __type;
314#ifdef __STDCPP_FLOAT32_T__
316 struct __is_floating<_Float32>
318 enum { __value = 1 };
319 typedef __true_type __type;
323#ifdef __STDCPP_FLOAT64_T__
325 struct __is_floating<_Float64>
327 enum { __value = 1 };
328 typedef __true_type __type;
332#ifdef __STDCPP_FLOAT128_T__
334 struct __is_floating<_Float128>
336 enum { __value = 1 };
337 typedef __true_type __type;
341#ifdef __STDCPP_BFLOAT16_T__
343 struct __is_floating<
__gnu_cxx::__bfloat16_t>
345 enum { __value = 1 };
346 typedef __true_type __type;
353 template<
typename _Tp>
354 struct __is_arithmetic
355 :
public __traitor<__is_integer<_Tp>, __is_floating<_Tp> >
361 template<
typename _Tp>
364 enum { __value = 0 };
365 typedef __false_type __type;
369 struct __is_char<char>
371 enum { __value = 1 };
372 typedef __true_type __type;
377 struct __is_char<wchar_t>
379 enum { __value = 1 };
380 typedef __true_type __type;
384 template<
typename _Tp>
387 enum { __value = 0 };
388 typedef __false_type __type;
392 struct __is_byte<char>
394 enum { __value = 1 };
395 typedef __true_type __type;
399 struct __is_byte<signed char>
401 enum { __value = 1 };
402 typedef __true_type __type;
406 struct __is_byte<unsigned char>
408 enum { __value = 1 };
409 typedef __true_type __type;
412#if __cplusplus >= 201703L
413 enum class byte :
unsigned char;
416 struct __is_byte<byte>
418 enum { __value = 1 };
419 typedef __true_type __type;
423#ifdef _GLIBCXX_USE_CHAR8_T
425 struct __is_byte<char8_t>
427 enum { __value = 1 };
428 typedef __true_type __type;
432 template<
typename>
struct iterator_traits;
435 template<
typename _Tp>
436 struct __is_nonvolatile_trivially_copyable
438 enum { __value = __is_trivially_copyable(_Tp) };
444 template<
typename _Tp>
445 struct __is_nonvolatile_trivially_copyable<volatile _Tp>
447 enum { __value = 0 };
451 template<
typename _OutputIter,
typename _InputIter>
454 enum { __value = 0 };
457 template<
typename _Tp>
458 struct __memcpyable<_Tp*, _Tp*>
459 : __is_nonvolatile_trivially_copyable<_Tp>
462 template<
typename _Tp>
463 struct __memcpyable<_Tp*,
const _Tp*>
464 : __is_nonvolatile_trivially_copyable<_Tp>
472 template<
typename _Iter1,
typename _Iter2>
475 enum { __value = 0 };
479 template<
typename _Tp>
480 struct __memcmpable<_Tp*, _Tp*>
481 : __is_nonvolatile_trivially_copyable<_Tp>
484 template<
typename _Tp>
485 struct __memcmpable<const _Tp*, _Tp*>
486 : __is_nonvolatile_trivially_copyable<_Tp>
489 template<
typename _Tp>
490 struct __memcmpable<_Tp*,
const _Tp*>
491 : __is_nonvolatile_trivially_copyable<_Tp>
500 template<
typename _Tp,
bool _TreatAsBytes =
501#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
502 __is_integer<_Tp>::__value
504 __is_byte<_Tp>::__value
507 struct __is_memcmp_ordered
509 static const bool __value = _Tp(-1) > _Tp(1);
512 template<
typename _Tp>
513 struct __is_memcmp_ordered<_Tp, false>
515 static const bool __value =
false;
519 template<
typename _Tp,
typename _Up,
bool = sizeof(_Tp) == sizeof(_Up)>
520 struct __is_memcmp_ordered_with
522 static const bool __value = __is_memcmp_ordered<_Tp>::__value
523 && __is_memcmp_ordered<_Up>::__value;
526 template<
typename _Tp,
typename _Up>
527 struct __is_memcmp_ordered_with<_Tp, _Up, false>
529 static const bool __value =
false;
532#if __cplusplus >= 201703L
533#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
536 struct __is_memcmp_ordered<
std::byte, false>
537 {
static constexpr bool __value =
true; };
542 struct __is_memcmp_ordered_with<
std::byte, std::byte, true>
543 {
static constexpr bool __value =
true; };
545 template<
typename _Tp,
bool _SameSize>
546 struct __is_memcmp_ordered_with<_Tp,
std::byte, _SameSize>
547 {
static constexpr bool __value =
false; };
549 template<
typename _Up,
bool _SameSize>
550 struct __is_memcmp_ordered_with<
std::byte, _Up, _SameSize>
551 {
static constexpr bool __value =
false; };
554#if __glibcxx_type_trait_variable_templates
555 template<
typename _ValT,
typename _Tp>
556 constexpr bool __can_use_memchr_for_find
558 = __is_byte<_ValT>::__value
560 && (is_same_v<_Tp, _ValT> || is_integral_v<_Tp>);
566 template<
typename _Tp>
567 struct __is_move_iterator
569 enum { __value = 0 };
570 typedef __false_type __type;
575 template<
typename _Iterator>
578 __miter_base(_Iterator __it)
581_GLIBCXX_END_NAMESPACE_VERSION
ISO C++ entities toplevel namespace is std.
GNU extensions for public use.