32#ifndef _CPP_TYPE_TRAITS_H
33#define _CPP_TYPE_TRAITS_H 1
36#pragma GCC system_header
41#if __glibcxx_type_trait_variable_templates
45#pragma GCC diagnostic push
46#pragma GCC diagnostic ignored "-Wlong-long"
78namespace std _GLIBCXX_VISIBILITY(default)
80_GLIBCXX_BEGIN_NAMESPACE_VERSION
82 struct __true_type { };
83 struct __false_type { };
87 {
typedef __false_type __type; };
90 struct __truth_type<true>
91 {
typedef __true_type __type; };
95 template<
class _Sp,
class _Tp>
98 enum { __value = bool(_Sp::__value) || bool(_Tp::__value) };
99 typedef typename __truth_type<__value>::__type __type;
103 template<
typename,
typename>
106 enum { __value = 0 };
107 typedef __false_type __type;
110 template<
typename _Tp>
111 struct __are_same<_Tp, _Tp>
113 enum { __value = 1 };
114 typedef __true_type __type;
120 template<
typename _Tp>
123 enum { __value = 0 };
124 typedef __false_type __type;
130 struct __is_integer<bool>
132 enum { __value = 1 };
133 typedef __true_type __type;
137 struct __is_integer<char>
139 enum { __value = 1 };
140 typedef __true_type __type;
144 struct __is_integer<signed char>
146 enum { __value = 1 };
147 typedef __true_type __type;
151 struct __is_integer<unsigned char>
153 enum { __value = 1 };
154 typedef __true_type __type;
157# ifdef __WCHAR_TYPE__
159 struct __is_integer<wchar_t>
161 enum { __value = 1 };
162 typedef __true_type __type;
166#ifdef _GLIBCXX_USE_CHAR8_T
168 struct __is_integer<char8_t>
170 enum { __value = 1 };
171 typedef __true_type __type;
175#if __cplusplus >= 201103L
177 struct __is_integer<char16_t>
179 enum { __value = 1 };
180 typedef __true_type __type;
184 struct __is_integer<char32_t>
186 enum { __value = 1 };
187 typedef __true_type __type;
192 struct __is_integer<short>
194 enum { __value = 1 };
195 typedef __true_type __type;
199 struct __is_integer<unsigned short>
201 enum { __value = 1 };
202 typedef __true_type __type;
206 struct __is_integer<int>
208 enum { __value = 1 };
209 typedef __true_type __type;
213 struct __is_integer<unsigned int>
215 enum { __value = 1 };
216 typedef __true_type __type;
220 struct __is_integer<long>
222 enum { __value = 1 };
223 typedef __true_type __type;
227 struct __is_integer<unsigned long>
229 enum { __value = 1 };
230 typedef __true_type __type;
234 struct __is_integer<long long>
236 enum { __value = 1 };
237 typedef __true_type __type;
241 struct __is_integer<unsigned long long>
243 enum { __value = 1 };
244 typedef __true_type __type;
247#define __INT_N(TYPE) \
250 struct __is_integer<TYPE> \
252 enum { __value = 1 }; \
253 typedef __true_type __type; \
257 struct __is_integer<unsigned TYPE> \
259 enum { __value = 1 }; \
260 typedef __true_type __type; \
263#ifdef __GLIBCXX_TYPE_INT_N_0
264__INT_N(__GLIBCXX_TYPE_INT_N_0)
266#ifdef __GLIBCXX_TYPE_INT_N_1
267__INT_N(__GLIBCXX_TYPE_INT_N_1)
269#ifdef __GLIBCXX_TYPE_INT_N_2
270__INT_N(__GLIBCXX_TYPE_INT_N_2)
272#ifdef __GLIBCXX_TYPE_INT_N_3
273__INT_N(__GLIBCXX_TYPE_INT_N_3)
276#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
287 template<
typename _Tp>
290 enum { __value = 0 };
291 typedef __false_type __type;
296 struct __is_floating<float>
298 enum { __value = 1 };
299 typedef __true_type __type;
303 struct __is_floating<double>
305 enum { __value = 1 };
306 typedef __true_type __type;
310 struct __is_floating<long double>
312 enum { __value = 1 };
313 typedef __true_type __type;
316#ifdef _GLIBCXX_USE_FLOAT128
318 struct __is_floating<__float128>
320 enum { __value = 1 };
321 typedef __true_type __type;
325#ifdef __STDCPP_FLOAT16_T__
327 struct __is_floating<_Float16>
329 enum { __value = 1 };
330 typedef __true_type __type;
334#ifdef __STDCPP_FLOAT32_T__
336 struct __is_floating<_Float32>
338 enum { __value = 1 };
339 typedef __true_type __type;
343#ifdef __STDCPP_FLOAT64_T__
345 struct __is_floating<_Float64>
347 enum { __value = 1 };
348 typedef __true_type __type;
352#ifdef __STDCPP_FLOAT128_T__
354 struct __is_floating<_Float128>
356 enum { __value = 1 };
357 typedef __true_type __type;
361#ifdef __STDCPP_BFLOAT16_T__
363 struct __is_floating<__gnu_cxx::__bfloat16_t>
365 enum { __value = 1 };
366 typedef __true_type __type;
373 template<
typename _Tp>
374 struct __is_arithmetic
375 :
public __traitor<__is_integer<_Tp>, __is_floating<_Tp> >
381 template<
typename _Tp>
384 enum { __value = 0 };
385 typedef __false_type __type;
389 struct __is_char<char>
391 enum { __value = 1 };
392 typedef __true_type __type;
397 struct __is_char<wchar_t>
399 enum { __value = 1 };
400 typedef __true_type __type;
404 template<
typename _Tp>
407 enum { __value = 0 };
408 typedef __false_type __type;
412 struct __is_byte<char>
414 enum { __value = 1 };
415 typedef __true_type __type;
419 struct __is_byte<signed char>
421 enum { __value = 1 };
422 typedef __true_type __type;
426 struct __is_byte<unsigned char>
428 enum { __value = 1 };
429 typedef __true_type __type;
433 enum class byte :
unsigned char;
436 struct __is_byte<byte>
438 enum { __value = 1 };
439 typedef __true_type __type;
443#ifdef _GLIBCXX_USE_CHAR8_T
445 struct __is_byte<char8_t>
447 enum { __value = 1 };
448 typedef __true_type __type;
453 template<
typename _Tp>
454 struct __is_nonvolatile_trivially_copyable
456 enum { __value = __is_trivially_copyable(_Tp) };
462 template<
typename _Tp>
463 struct __is_nonvolatile_trivially_copyable<volatile _Tp>
465 enum { __value = 0 };
469 template<
typename _OutputIter,
typename _InputIter>
472 enum { __value = 0 };
476 template<
typename _Tp>
477 struct __memcpyable<_Tp*, _Tp*>
478 : __is_nonvolatile_trivially_copyable<_Tp>
482 template<
typename _Tp>
483 struct __memcpyable<_Tp*,
const _Tp*>
484 : __is_nonvolatile_trivially_copyable<_Tp>
487 template<
typename _Tp>
struct __memcpyable_integer;
492 template<
typename _Tp,
typename _Up>
493 struct __memcpyable<_Tp*, _Up*>
496 __value = __memcpyable_integer<_Tp>::__width != 0
497 && ((int)__memcpyable_integer<_Tp>::__width
498 == (int)__memcpyable_integer<_Up>::__width)
503 template<
typename _Tp,
typename _Up>
504 struct __memcpyable<_Tp*,
const _Up*>
505 : __memcpyable<_Tp*, _Up*>
508 template<
typename _Tp>
509 struct __memcpyable_integer
512 __width = __is_integer<_Tp>::__value ? (
sizeof(_Tp) * __CHAR_BIT__) : 0
517 template<
typename _Tp>
518 struct __memcpyable_integer<volatile _Tp>
519 {
enum { __width = 0 }; };
522#if defined __GLIBCXX_TYPE_INT_N_0 && __GLIBCXX_BITSIZE_INT_N_0 % __CHAR_BIT__
525 struct __memcpyable_integer<__GLIBCXX_TYPE_INT_N_0>
526 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_0 }; };
529 struct __memcpyable_integer<unsigned __GLIBCXX_TYPE_INT_N_0>
530 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_0 }; };
532#if defined __GLIBCXX_TYPE_INT_N_1 && __GLIBCXX_BITSIZE_INT_N_1 % __CHAR_BIT__
535 struct __memcpyable_integer<__GLIBCXX_TYPE_INT_N_1>
536 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_1 }; };
539 struct __memcpyable_integer<unsigned __GLIBCXX_TYPE_INT_N_1>
540 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_1 }; };
542#if defined __GLIBCXX_TYPE_INT_N_2 && __GLIBCXX_BITSIZE_INT_N_2 % __CHAR_BIT__
545 struct __memcpyable_integer<__GLIBCXX_TYPE_INT_N_2>
546 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_2 }; };
549 struct __memcpyable_integer<unsigned __GLIBCXX_TYPE_INT_N_2>
550 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_2 }; };
552#if defined __GLIBCXX_TYPE_INT_N_3 && __GLIBCXX_BITSIZE_INT_N_3 % __CHAR_BIT__
555 struct __memcpyable_integer<__GLIBCXX_TYPE_INT_N_3>
556 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_3 }; };
559 struct __memcpyable_integer<unsigned __GLIBCXX_TYPE_INT_N_3>
560 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_3 }; };
563#if _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 && _GLIBCXX_LDOUBLE_IS_IEEE_BINARY64
565 struct __memcpyable<double*,
long double*> {
enum { __value =
true }; };
567 struct __memcpyable<long double*,
double*> {
enum { __value =
true }; };
570#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
572 struct __memcpyable<_Float32*,
float*> {
enum { __value =
true }; };
574 struct __memcpyable<float*, _Float32*> {
enum { __value =
true }; };
577#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
579 struct __memcpyable<_Float64*,
double*> {
enum { __value =
true }; };
581 struct __memcpyable<double*, _Float64*> {
enum { __value =
true }; };
584#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
586 struct __memcpyable<_Float128*,
long double*> {
enum { __value =
true }; };
588 struct __memcpyable<long double*, _Float128*> {
enum { __value =
true }; };
596 template<
typename _Iter1,
typename _Iter2>
599 enum { __value = 0 };
603 template<
typename _Tp>
604 struct __memcmpable<_Tp*, _Tp*>
605 : __is_nonvolatile_trivially_copyable<_Tp>
608 template<
typename _Tp>
609 struct __memcmpable<const _Tp*, _Tp*>
610 : __is_nonvolatile_trivially_copyable<_Tp>
613 template<
typename _Tp>
614 struct __memcmpable<_Tp*,
const _Tp*>
615 : __is_nonvolatile_trivially_copyable<_Tp>
624 template<
typename _Tp,
bool _TreatAsBytes =
625#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
626 __is_integer<_Tp>::__value
628 __is_byte<_Tp>::__value
631 struct __is_memcmp_ordered
633 static const bool __value = _Tp(-1) > _Tp(1);
636 template<
typename _Tp>
637 struct __is_memcmp_ordered<_Tp, false>
639 static const bool __value =
false;
643 template<
typename _Tp,
typename _Up,
bool = sizeof(_Tp) == sizeof(_Up)>
644 struct __is_memcmp_ordered_with
646 static const bool __value = __is_memcmp_ordered<_Tp>::__value
647 && __is_memcmp_ordered<_Up>::__value;
650 template<
typename _Tp,
typename _Up>
651 struct __is_memcmp_ordered_with<_Tp, _Up, false>
653 static const bool __value =
false;
656#if __cplusplus >= 201703L
657#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
660 struct __is_memcmp_ordered<std::byte, false>
661 {
static constexpr bool __value =
true; };
666 struct __is_memcmp_ordered_with<std::byte, std::byte, true>
667 {
static constexpr bool __value =
true; };
669 template<
typename _Tp,
bool _SameSize>
670 struct __is_memcmp_ordered_with<_Tp, std::byte, _SameSize>
671 {
static constexpr bool __value =
false; };
673 template<
typename _Up,
bool _SameSize>
674 struct __is_memcmp_ordered_with<std::byte, _Up, _SameSize>
675 {
static constexpr bool __value =
false; };
678#if __glibcxx_type_trait_variable_templates
679 template<
typename _ValT,
typename _Tp>
680 constexpr bool __can_use_memchr_for_find
682 = __is_byte<_ValT>::__value
684 && (is_same_v<_Tp, _ValT> || is_integral_v<_Tp>);
690 template<
typename _Tp>
691 struct __is_move_iterator
693 enum { __value = 0 };
694 typedef __false_type __type;
699 template<
typename _Iterator>
702 __miter_base(_Iterator __it)
705_GLIBCXX_END_NAMESPACE_VERSION
709#pragma GCC diagnostic pop
ISO C++ entities toplevel namespace is std.