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 }; };
525 struct __memcpyable_integer<bool>
526 {
enum { __width = 0 }; };
529#if defined __GLIBCXX_TYPE_INT_N_0 && __GLIBCXX_BITSIZE_INT_N_0 % __CHAR_BIT__
532 struct __memcpyable_integer<__GLIBCXX_TYPE_INT_N_0>
533 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_0 }; };
536 struct __memcpyable_integer<unsigned __GLIBCXX_TYPE_INT_N_0>
537 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_0 }; };
539#if defined __GLIBCXX_TYPE_INT_N_1 && __GLIBCXX_BITSIZE_INT_N_1 % __CHAR_BIT__
542 struct __memcpyable_integer<__GLIBCXX_TYPE_INT_N_1>
543 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_1 }; };
546 struct __memcpyable_integer<unsigned __GLIBCXX_TYPE_INT_N_1>
547 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_1 }; };
549#if defined __GLIBCXX_TYPE_INT_N_2 && __GLIBCXX_BITSIZE_INT_N_2 % __CHAR_BIT__
552 struct __memcpyable_integer<__GLIBCXX_TYPE_INT_N_2>
553 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_2 }; };
556 struct __memcpyable_integer<unsigned __GLIBCXX_TYPE_INT_N_2>
557 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_2 }; };
559#if defined __GLIBCXX_TYPE_INT_N_3 && __GLIBCXX_BITSIZE_INT_N_3 % __CHAR_BIT__
562 struct __memcpyable_integer<__GLIBCXX_TYPE_INT_N_3>
563 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_3 }; };
566 struct __memcpyable_integer<unsigned __GLIBCXX_TYPE_INT_N_3>
567 {
enum { __width = __GLIBCXX_BITSIZE_INT_N_3 }; };
570#if _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 && _GLIBCXX_LDOUBLE_IS_IEEE_BINARY64
572 struct __memcpyable<double*,
long double*> {
enum { __value =
true }; };
574 struct __memcpyable<long double*,
double*> {
enum { __value =
true }; };
577#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
579 struct __memcpyable<_Float32*,
float*> {
enum { __value =
true }; };
581 struct __memcpyable<float*, _Float32*> {
enum { __value =
true }; };
584#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
586 struct __memcpyable<_Float64*,
double*> {
enum { __value =
true }; };
588 struct __memcpyable<double*, _Float64*> {
enum { __value =
true }; };
591#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
593 struct __memcpyable<_Float128*,
long double*> {
enum { __value =
true }; };
595 struct __memcpyable<long double*, _Float128*> {
enum { __value =
true }; };
603 template<
typename _Iter1,
typename _Iter2>
606 enum { __value = 0 };
610 template<
typename _Tp>
611 struct __memcmpable<_Tp*, _Tp*>
612 : __is_nonvolatile_trivially_copyable<_Tp>
615 template<
typename _Tp>
616 struct __memcmpable<const _Tp*, _Tp*>
617 : __is_nonvolatile_trivially_copyable<_Tp>
620 template<
typename _Tp>
621 struct __memcmpable<_Tp*,
const _Tp*>
622 : __is_nonvolatile_trivially_copyable<_Tp>
631 template<
typename _Tp,
bool _TreatAsBytes =
632#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
633 __is_integer<_Tp>::__value
635 __is_byte<_Tp>::__value
638 struct __is_memcmp_ordered
640 static const bool __value = _Tp(-1) > _Tp(1);
643 template<
typename _Tp>
644 struct __is_memcmp_ordered<_Tp, false>
646 static const bool __value =
false;
650 template<
typename _Tp,
typename _Up,
bool = sizeof(_Tp) == sizeof(_Up)>
651 struct __is_memcmp_ordered_with
653 static const bool __value = __is_memcmp_ordered<_Tp>::__value
654 && __is_memcmp_ordered<_Up>::__value;
657 template<
typename _Tp,
typename _Up>
658 struct __is_memcmp_ordered_with<_Tp, _Up, false>
660 static const bool __value =
false;
663#if __cplusplus >= 201703L
664#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
667 struct __is_memcmp_ordered<std::byte, false>
668 {
static constexpr bool __value =
true; };
673 struct __is_memcmp_ordered_with<std::byte, std::byte, true>
674 {
static constexpr bool __value =
true; };
676 template<
typename _Tp,
bool _SameSize>
677 struct __is_memcmp_ordered_with<_Tp, std::byte, _SameSize>
678 {
static constexpr bool __value =
false; };
680 template<
typename _Up,
bool _SameSize>
681 struct __is_memcmp_ordered_with<std::byte, _Up, _SameSize>
682 {
static constexpr bool __value =
false; };
685#if __glibcxx_type_trait_variable_templates
686 template<
typename _ValT,
typename _Tp>
687 constexpr bool __can_use_memchr_for_find
689 = __is_byte<_ValT>::__value
691 && (is_same_v<_Tp, _ValT> || is_integral_v<_Tp>);
697 template<
typename _Tp>
698 struct __is_move_iterator
700 enum { __value = 0 };
701 typedef __false_type __type;
706 template<
typename _Iterator>
709 __miter_base(_Iterator __it)
712_GLIBCXX_END_NAMESPACE_VERSION
716#pragma GCC diagnostic pop
ISO C++ entities toplevel namespace is std.