36#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
65#ifndef ETL_TYPE_TRAITS_INCLUDED
66#define ETL_TYPE_TRAITS_INCLUDED
70#include "static_assert.h"
80#if ETL_USING_STL && ETL_USING_CPP11
81 #include <type_traits>
87 template <
typename...>
91#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
99 template <
typename T, T VALUE>
100 struct integral_constant
102 static const T value = VALUE;
104 typedef T value_type;
105 typedef integral_constant<T, VALUE> type;
107 operator value_type()
const
114 typedef integral_constant<bool, false>
false_type;
115 typedef integral_constant<bool, true> true_type;
117 template <
typename T, T VALUE>
118 const T integral_constant<T, VALUE>::value;
121 template <
typename T, T VALUE>
127 using bool_constant = integral_constant<bool, B>;
135 inline constexpr bool bool_constant_v = bool_constant<B>::value;
140 template <
typename T>
146 template <
typename T>
147 inline constexpr bool negation_v = negation<T>::value;
152 template <
typename T>
struct remove_reference {
typedef T type; };
153 template <
typename T>
struct remove_reference<T&> {
typedef T type; };
155 template <
typename T>
struct remove_reference<T&&> {
typedef T type; };
159 template <
typename T>
160 using remove_reference_t =
typename remove_reference<T>::type;
165 template <
typename T>
struct remove_pointer {
typedef T type; };
166 template <
typename T>
struct remove_pointer<T*> {
typedef T type; };
167 template <
typename T>
struct remove_pointer<const T*> {
typedef const T type; };
168 template <
typename T>
struct remove_pointer<volatile T*> {
typedef volatile T type; };
169 template <
typename T>
struct remove_pointer<const volatile T*> {
typedef const volatile T type; };
170 template <
typename T>
struct remove_pointer<T*
const> {
typedef T type; };
171 template <
typename T>
struct remove_pointer<const T*
const> {
typedef const T type; };
172 template <
typename T>
struct remove_pointer<volatile T*
const> {
typedef volatile T type; };
173 template <
typename T>
struct remove_pointer<const volatile T*
const> {
typedef const volatile T type; };
176 template <
typename T>
177 using remove_pointer_t =
typename remove_pointer<T>::type;
182 template <
typename T>
struct add_pointer {
typedef typename remove_reference<T>::type* type; };
185 template <
typename T>
186 using add_pointer_t =
typename add_pointer<T>::type;
191 template <
typename T>
struct is_const :
false_type {};
192 template <
typename T>
struct is_const<const T> : true_type {};
193 template <
typename T>
struct is_const<const volatile T> : true_type {};
196 template <
typename T>
197 inline constexpr bool is_const_v = is_const<T>::value;
202 template <
typename T>
struct remove_const {
typedef T type; };
203 template <
typename T>
struct remove_const<const T> {
typedef T type; };
206 template <
typename T>
207 using remove_const_t =
typename remove_const<T>::type;
212 template <
typename T>
struct add_const {
typedef const T type; };
213 template <
typename T>
struct add_const<const T> {
typedef const T type; };
216 template <
typename T>
217 using add_const_t =
typename add_const<T>::type;
222 template <
typename T>
struct is_volatile :
false_type {};
223 template <
typename T>
struct is_volatile<volatile T> : true_type {};
224 template <
typename T>
struct is_volatile<const volatile T> : true_type {};
227 template <
typename T>
228 inline constexpr bool is_volatile_v = is_volatile<T>::value;
233 template <
typename T>
struct remove_volatile {
typedef T type; };
234 template <
typename T>
struct remove_volatile<volatile T> {
typedef T type; };
237 template <
typename T>
238 using remove_volatile_t =
typename remove_volatile<T>::type;
243 template <
typename T>
struct add_volatile {
typedef volatile T type; };
244 template <
typename T>
struct add_volatile<volatile T> {
typedef volatile T type; };
247 template <
typename T>
248 using add_volatile_t =
typename add_volatile<T>::type;
253 template <
typename T>
struct remove_cv
255 typedef typename remove_volatile<typename remove_const<T>::type>::type type;
259 template <
typename T>
260 using remove_cv_t =
typename remove_cv<T>::type;
265 template <
typename T>
struct add_cv
267 typedef typename add_volatile<typename add_const<T>::type>::type type;
271 template <
typename T>
272 using add_cv_t =
typename add_cv<T>::type;
277 template <
typename T>
struct remove_cvref
279 typedef typename remove_cv<typename remove_reference<T>::type>::type type;
283 template <
typename T>
284 using remove_cvref_t =
typename remove_cvref<T>::type;
289 template <
typename T>
struct is_integral :
false_type {};
290 template <>
struct is_integral<bool> : true_type {};
291 template <>
struct is_integral<char> : true_type {};
292 template <>
struct is_integral<unsigned char> : true_type {};
293 template <>
struct is_integral<signed char> : true_type {};
294 template <>
struct is_integral<wchar_t> : true_type {};
295 template <>
struct is_integral<short> : true_type {};
296 template <>
struct is_integral<unsigned short> : true_type {};
297 template <>
struct is_integral<int> : true_type {};
298 template <>
struct is_integral<unsigned int> : true_type {};
299 template <>
struct is_integral<long> : true_type {};
300 template <>
struct is_integral<unsigned long> : true_type {};
301 template <>
struct is_integral<long long> : true_type {};
302 template <>
struct is_integral<unsigned long long> : true_type {};
303 template <
typename T>
struct is_integral<const T> : is_integral<T> {};
304 template <
typename T>
struct is_integral<volatile T> : is_integral<T> {};
305 template <
typename T>
struct is_integral<const volatile T> : is_integral<T> {};
308 template <
typename T>
309 inline constexpr bool is_integral_v = is_integral<T>::value;
314 template <
typename T>
struct is_signed :
false_type {};
316 template <> struct is_signed<wchar_t> : public etl::bool_constant<static_cast<bool>(wchar_t(-1) < wchar_t(0))> {};
317 template <> struct is_signed<signed char> : true_type {};
318 template <> struct is_signed<short> : true_type {};
319 template <> struct is_signed<int> : true_type {};
320 template <> struct is_signed<long> : true_type {};
321 template <> struct is_signed<long long> : true_type {};
322 template <> struct is_signed<float> : true_type {};
323 template <> struct is_signed<double> : true_type {};
324 template <> struct is_signed<long double> : true_type {};
325 template <typename T> struct is_signed<const T> : is_signed<T> {};
326 template <typename T> struct is_signed<volatile T> : is_signed<T> {};
327 template <typename T> struct is_signed<const volatile T> : is_signed<T> {};
330 template <typename T>
331 inline constexpr bool is_signed_v = is_signed<T>::value;
336 template <typename T> struct is_unsigned : false_type {};
337 template <> struct is_unsigned<bool> : true_type {};
338 template <> struct is_unsigned<char> : etl::bool_constant<(char(255) > 0)> {};
339 template <> struct is_unsigned<unsigned char> : true_type {};
340 template <> struct is_unsigned<wchar_t> : public etl::bool_constant<(wchar_t(-1) > wchar_t(0))> {};
341 template <>
struct is_unsigned<unsigned short> : true_type {};
342 template <>
struct is_unsigned<unsigned int> : true_type {};
343 template <>
struct is_unsigned<unsigned long> : true_type {};
344 template <>
struct is_unsigned<unsigned long long> : true_type {};
345 template <
typename T>
struct is_unsigned<const T> : is_unsigned<T> {};
346 template <
typename T>
struct is_unsigned<volatile T> : is_unsigned<T> {};
347 template <
typename T>
struct is_unsigned<const volatile T> : is_unsigned<T> {};
350 template <
typename T>
351 inline constexpr bool is_unsigned_v = is_unsigned<T>::value;
356 template <
typename T>
struct is_floating_point :
false_type {};
357 template <>
struct is_floating_point<float> : true_type {};
358 template <>
struct is_floating_point<double> : true_type {};
359 template <>
struct is_floating_point<long double> : true_type {};
360 template <
typename T>
struct is_floating_point<const T> : is_floating_point<T> {};
361 template <
typename T>
struct is_floating_point<volatile T> : is_floating_point<T> {};
362 template <
typename T>
struct is_floating_point<const volatile T> : is_floating_point<T> {};
365 template <
typename T>
366 inline constexpr bool is_floating_point_v = is_floating_point<T>::value;
371 template <
typename T1,
typename T2>
struct is_same :
public false_type {};
372 template <
typename T>
struct is_same<T, T> :
public true_type {};
375 template <
typename T1,
typename T2>
376 inline constexpr bool is_same_v = is_same<T1, T2>::value;
381 template<
typename T>
struct is_void :
false_type {};
382 template<>
struct is_void<void> : true_type {};
385 template <
typename T>
386 inline constexpr bool is_void_v = is_void<T>::value;
391 template<
typename T>
struct is_arithmetic :
etl::bool_constant<is_integral<T>::value || is_floating_point<T>::value> {};
394 template <
typename T>
395 inline constexpr bool is_arithmetic_v = is_arithmetic<T>::value;
400 template <
typename T>
struct is_fundamental :
etl::bool_constant<is_arithmetic<T>::value || is_void<T>::value> {};
403 template <
typename T>
404 inline constexpr bool is_fundamental_v = is_fundamental<T>::value;
409 template <
typename T>
struct is_compound :
etl::bool_constant<!is_fundamental<T>::value> {};
412 template <
typename T>
413 inline constexpr bool is_compound_v = is_compound<T>::value;
418 template <
typename T>
struct is_array :
false_type {};
419 template <
typename T>
struct is_array<T[]> : true_type {};
420 template <
typename T,
size_t MAXN>
struct is_array<T[MAXN]> : true_type {};
423 template <
typename T>
424 inline constexpr bool is_array_v = is_array<T>::value;
429 template<
typename T>
struct is_pointer_helper :
false_type {};
430 template<
typename T>
struct is_pointer_helper<T*> : true_type {};
431 template<
typename T>
struct is_pointer : is_pointer_helper<typename remove_cv<T>::type> {};
434 template <
typename T>
435 inline constexpr bool is_pointer_v = is_pointer<T>::value;
440 template<
typename T>
struct is_lvalue_reference_helper :
false_type {};
441 template<
typename T>
struct is_lvalue_reference_helper<T&> : true_type {};
442 template<
typename T>
struct is_lvalue_reference : is_lvalue_reference_helper<typename remove_cv<T>::type> {};
445 template <
typename T>
452 template<
typename T>
struct is_rvalue_reference_helper :
false_type {};
453 template<
typename T>
struct is_rvalue_reference_helper<T&&> : true_type {};
454 template<
typename T>
struct is_rvalue_reference : is_rvalue_reference_helper<typename remove_cv<T>::type> {};
457 template <
typename T>
458 inline constexpr bool is_rvalue_reference_v = etl::is_rvalue_reference<T>::value;
465 template<
typename T>
struct is_reference : integral_constant<bool,
466 is_lvalue_reference<T>::value
468 || is_rvalue_reference<T>::value
473 template <
typename T>
474 inline constexpr bool is_reference_v = is_reference<T>::value;
480 template <
typename T>
struct is_pod :
etl::bool_constant<etl::is_fundamental<T>::value || etl::is_pointer<T>::value> {};
483 template <
typename T>
489 template <
bool B,
typename T,
typename F>
struct conditional {
typedef T type; };
490 template <
typename T,
typename F>
struct conditional<false, T, F> {
typedef F type; };
493 template <
bool B,
typename T,
typename F>
494 using conditional_t =
typename conditional<B, T, F>::type;
499 template <
typename T>
struct make_signed {
typedef T type; };
500 template <>
struct make_signed<char> {
typedef signed char type; };
501 template <>
struct make_signed<unsigned char> {
typedef signed char type; };
503 template <>
struct make_signed<wchar_t>
509 void>::type>::type type;
512 template <>
struct make_signed<unsigned short> {
typedef short type; };
513 template <>
struct make_signed<unsigned int> {
typedef int type; };
514 template <>
struct make_signed<unsigned long> {
typedef long type; };
515 template <>
struct make_signed<unsigned long long> {
typedef long long type; };
516 template <
typename T>
struct make_signed<const T> : add_const<typename make_signed<T>::type> {};
517 template <
typename T>
struct make_signed<volatile T> : add_volatile<typename make_signed<T>::type> {};
518 template <
typename T>
struct make_signed<const volatile T> : add_const<typename add_volatile<typename make_signed<T>::type>::type> {};
521 template <
typename T>
522 using make_signed_t =
typename make_signed<T>::type;
527 template <
typename T>
struct make_unsigned {
typedef T type; };
528 template <>
struct make_unsigned<char> {
typedef unsigned char type; };
529 template <>
struct make_unsigned<signed char> {
typedef unsigned char type; };
530 template <>
struct make_unsigned<short> {
typedef unsigned short type; };
532 template <>
struct make_unsigned<wchar_t>
538 void>::type>::type type;
541 template <>
struct make_unsigned<int> {
typedef unsigned int type; };
542 template <>
struct make_unsigned<long> {
typedef unsigned long type; };
543 template <>
struct make_unsigned<long long> {
typedef unsigned long long type; };
544 template <
typename T>
struct make_unsigned<const T> : add_const<typename make_unsigned<T>::type> {};
545 template <
typename T>
struct make_unsigned<volatile T> : add_volatile<typename make_unsigned<T>::type> {};
546 template <
typename T>
struct make_unsigned<const volatile T> : add_const<typename add_volatile<typename make_unsigned<T>::type>::type> {};
549 template <
typename T>
550 using make_unsigned_t =
typename make_unsigned<T>::type;
555 template <
bool B,
typename T =
void>
struct enable_if {};
556 template <
typename T>
struct enable_if<true, T> {
typedef T type; };
559 template <
bool B,
typename T =
void>
560 using enable_if_t =
typename enable_if<B, T>::type;
565 template <
typename T,
unsigned MAXN = 0U>
566 struct extent : integral_constant<size_t, 0U> {};
568 template <
typename T>
569 struct extent<T[], 0> : integral_constant<size_t, 0U> {};
571 template <
typename T,
unsigned MAXN>
572 struct extent<T[], MAXN> : integral_constant<size_t, extent<T, MAXN - 1>::value> {};
574 template <
typename T,
unsigned MAXN>
575 struct extent<T[MAXN], 0> : integral_constant<size_t, MAXN> {};
577 template <
typename T,
unsigned I,
unsigned MAXN>
578 struct extent<T[I], MAXN> : integral_constant<size_t, extent<T, MAXN - 1>::value> {};
581 template <
typename T,
unsigned N = 0U>
582 inline constexpr size_t extent_v = extent<T, N>::value;
587 template <
typename T>
struct remove_extent {
typedef T type; };
588 template <
typename T>
struct remove_extent<T[]> {
typedef T type; };
589 template <
typename T,
size_t MAXN>
struct remove_extent<T[MAXN]> {
typedef T type; };
592 template <
typename T>
593 using remove_extent_t =
typename remove_extent<T>::type;
598 template <
typename T>
struct remove_all_extents {
typedef T type; };
599 template <
typename T>
struct remove_all_extents<T[]> {
typedef typename remove_all_extents<T>::type type; };
600 template <
typename T,
size_t MAXN>
struct remove_all_extents<T[MAXN]> {
typedef typename remove_all_extents<T>::type type; };
603 template <
typename T>
604 using remove_all_extents_t =
typename remove_all_extents<T>::type;
609 template <
typename T>
struct rank : integral_constant<size_t, 0> {};
610 template <
typename T>
struct rank<T[]> :
public integral_constant<size_t, rank<T>::value + 1> {};
611 template <
typename T,
size_t MAXN>
struct rank<T[MAXN]> :
public integral_constant<size_t, rank<T>::value + 1> {};
614 template <
typename T>
615 inline constexpr size_t rank_v = rank<T>::value;
620 template <
typename T>
623 typedef typename etl::remove_reference<T>::type U;
625 typename etl::remove_extent<U>::type*,
626 typename etl::remove_cv<U>::type>::type type;
630 template <
typename T>
631 using decay_t =
typename decay<T>::type;
636 template<
typename TBase,
643 template<
typename T>
struct dummy {};
644 struct internal: TDerived, dummy<int>{};
646 static TBase* check(TBase*) {
return (TBase*)0; }
649 static char check(dummy<T>*) {
return 0; }
653 static const bool value = (
sizeof(check((internal*)0)) ==
sizeof(TBase*));
657 template<
typename TBase,
typename TDerived>
658 struct is_base_of<TBase, TDerived, true>
660 static const bool value =
false;
664 template <
typename T1,
typename T2>
665 inline constexpr bool is_base_of_v = is_base_of<T1, T2>::value;
670 namespace private_type_traits
672 template <
typename T>
char test(
int T::*);
674 struct dummy {
char c[2]; };
675 template <
typename T> dummy test(...);
678 template <
typename T>
682 template <
typename T>
683 inline constexpr bool is_class_v = is_class<T>::value;
688 template <
typename T>
struct add_lvalue_reference {
typedef T& type; };
689 template <
typename T>
struct add_lvalue_reference<T&> {
typedef T& type; };
690 template <>
struct add_lvalue_reference<void> {
typedef void type; };
691 template <>
struct add_lvalue_reference<const void> {
typedef const void type; };
692 template <>
struct add_lvalue_reference<volatile void> {
typedef volatile void type; };
693 template <>
struct add_lvalue_reference<const volatile void> {
typedef const volatile void type; };
696 template <
typename T>
697 using add_lvalue_reference_t =
typename etl::add_lvalue_reference<T>::type;
703 template <
typename T>
struct add_rvalue_reference {
using type = T && ; };
704 template <
typename T>
struct add_rvalue_reference<T&> {
using type = T & ; };
705 template <>
struct add_rvalue_reference<void> {
using type = void; };
706 template <>
struct add_rvalue_reference<const void> {
using type =
const void; };
707 template <>
struct add_rvalue_reference<volatile void> {
using type =
volatile void; };
708 template <>
struct add_rvalue_reference<const volatile void> {
using type =
const volatile void; };
712 template <
typename T>
713 using add_rvalue_reference_t =
typename etl::add_rvalue_reference<T>::type;
719 template <
typename T>
720 typename etl::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
729 namespace private_type_traits
732 template <
typename T,
typename =
int>
739 template <
typename T>
740 struct is_convertible_to_int<T, decltype(static_cast<int>(declval<T>()))>
746 template <
typename T>
748 : integral_constant<bool, private_type_traits::is_convertible_to_int<T>::value &&
749 !is_class<T>::value &&
750 !is_arithmetic<T>::value &&
751 !is_reference<T>::value>
756 template <
typename T>
757 inline constexpr bool is_enum_v = etl::is_enum<T>::value;
765 namespace private_type_traits
770 template <
typename T>
771 auto returnable(
int)->true_type_for<T()>;
774 auto returnable(...)->etl::false_type;
776 template <
typename TFrom,
typename TTo>
777 auto nonvoid_convertible(
int)->true_type_for<
decltype(etl::declval<void(&)(TTo)>()(etl::declval<TFrom>()))
779 template <
typename,
typename>
780 auto nonvoid_convertible(...)->etl::false_type;
783#if defined(ETL_COMPILER_ARM5)
784 template <
typename TFrom,
typename TTo>
787 template <
typename TFrom,
typename TTo>
788 struct is_convertible :
etl::bool_constant<(decltype(private_type_traits::returnable<TTo>(0))::value &&
789 decltype(private_type_traits::nonvoid_convertible<TFrom, TTo>(0))::value) ||
790 (etl::is_void<TFrom>::value && etl::is_void<TTo>::value)> {};
795 template <
typename TFrom,
typename TTo >
796 inline constexpr bool is_convertible_v = etl::is_convertible<TFrom, TTo>::value;
802#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5)
803 template <
typename T>
struct alignment_of : integral_constant<size_t, alignof(T)> { };
804#elif defined(ETL_COMPILER_MICROSOFT)
805 template <
typename T>
struct alignment_of : integral_constant<size_t, size_t(__alignof(T))> {};
806#elif defined(ETL_COMPILER_IAR) || defined(ETL_COMPILER_TI)
807 template <
typename T>
struct alignment_of : integral_constant<size_t, size_t(__ALIGNOF__(T))> {};
809 template <
typename T>
struct alignment_of : integral_constant<size_t, size_t(__alignof__(T))> {};
814 template <>
struct alignment_of<void> : integral_constant <size_t, 0> {};
815 template <>
struct alignment_of<const void> : integral_constant <size_t, 0> {};
818 template <
typename T>
831 template <
typename T, T VALUE>
840 template <
typename T, T VALUE>
841 inline constexpr T integral_constant_v = std::integral_constant<T, VALUE>::value;
861 template <
typename T>
864 template <
typename T>
871 template <
typename T>
872 inline constexpr bool negation_v = std::negation_v<T>;
881 template <
typename T>
882 using remove_reference_t =
typename std::remove_reference<T>::type;
891 template <
typename T>
892 using remove_pointer_t =
typename std::remove_pointer<T>::type;
898 template <
typename T>
struct add_pointer : std::add_pointer<T> {};
901 template <
typename T>
902 using add_pointer_t =
typename std::add_pointer<T>::type;
908 template <
typename T>
struct is_const : std::is_const<T> {};
911 template <
typename T>
912 inline constexpr bool is_const_v = std::is_const_v<T>;
921 template <
typename T>
922 using remove_const_t =
typename std::remove_const<T>::type;
928 template <
typename T>
struct add_const : std::add_const<T> {};
931 template <
typename T>
932 using add_const_t =
typename std::add_const<T>::type;
938 template <
typename T>
struct is_volatile : std::is_volatile<T> {};
941 template <
typename T>
942 inline constexpr bool is_volatile_v = std::is_volatile_v<T>;
951 template <
typename T>
952 using remove_volatile_t =
typename std::remove_volatile<T>::type;
961 template <
typename T>
962 using add_volatile_t =
typename std::add_volatile<T>::type;
968 template <
typename T>
struct remove_cv : std::remove_cv<T> {};
971 template <
typename T>
972 using remove_cv_t =
typename std::remove_cv<T>::type;
978 template <
typename T>
struct add_cv : std::add_cv<T> {};
981 template <
typename T>
982 using add_cv_t =
typename std::add_cv<T>::type;
990 typedef typename std::remove_cv<typename std::remove_reference<T>::type>::type type;
994 template <
typename T>
995 using remove_cvref_t =
typename etl::remove_cvref<T>::type;
1004 template <
typename T>
1005 inline constexpr bool is_integral_v = std::is_integral_v<T>;
1011 template <
typename T>
struct is_signed : std::is_signed<T> {};
1014 template <
typename T>
1015 inline constexpr bool is_signed_v = std::is_signed_v<T>;
1024 template <
typename T>
1025 inline constexpr bool is_unsigned_v = std::is_unsigned_v<T>;
1034 template <
typename T>
1035 inline constexpr bool is_floating_point_v = std::is_floating_point_v<T>;
1041 template <
typename T1,
typename T2>
struct is_same : std::is_same<T1, T2> {};
1044 template <
typename T1,
typename T2>
1045 inline constexpr bool is_same_v = std::is_same_v<T1, T2>;
1051 template<
typename T>
struct is_void : std::is_void<T> {};
1054 template <
typename T>
1055 inline constexpr bool is_void_v = std::is_void_v<T>;
1064 template <
typename T>
1065 inline constexpr bool is_arithmetic_v = std::is_arithmetic_v<T>;
1074 template <
typename T>
1075 inline constexpr bool is_fundamental_v = std::is_fundamental_v<T>;
1084 template <
typename T>
1085 inline constexpr bool is_compound_v = std::is_compound_v<T>;
1091 template <
typename T>
struct is_array : std::is_array<T> {};
1094 template <
typename T>
1095 inline constexpr bool is_array_v = std::is_array_v<T>;
1104 template <
typename T>
1105 inline constexpr bool is_pointer_v = std::is_pointer_v<T>;
1114 template <
typename T>
1115 inline constexpr bool is_reference_v = std::is_reference_v<T>;
1124 template <
typename T>
1125 inline constexpr bool is_lvalue_reference_v = std::is_lvalue_reference_v<T>;
1132 template<
typename T>
struct is_rvalue_reference : std::is_rvalue_reference<T> {};
1135 template <
typename T>
1136 inline constexpr bool is_rvalue_reference_v = std::is_rvalue_reference_v<T>;
1143 template <
typename T>
1144 struct is_pod : std::integral_constant<bool, std::is_standard_layout<T>::value && std::is_trivial<T>::value> {};
1147 template <
typename T>
1148 inline constexpr bool is_pod_v = std::is_standard_layout_v<T> && std::is_trivial_v<T>;
1151#if defined(ETL_COMPILER_GCC)
1152 #if ETL_COMPILER_VERSION >= 5
1153 #define ETL_GCC_V5_TYPE_TRAITS_SUPPORTED
1160 template <
bool B,
typename T,
typename F>
struct conditional {
typedef T type; };
1161 template <
typename T,
typename F>
struct conditional<false, T, F> {
typedef F type; };
1164 template <
bool B,
typename T,
typename F>
1165 using conditional_t =
typename conditional<B, T, F>::type;
1174 template <
typename T>
1175 using make_signed_t =
typename std::make_signed<T>::type;
1184 template <
typename T>
1185 using make_unsigned_t =
typename std::make_unsigned<T>::type;
1191 template <
bool B,
typename T =
void>
struct enable_if : std::enable_if<B, T> {};
1194 template <
bool B,
typename T =
void>
1195 using enable_if_t =
typename std::enable_if<B, T>::type;
1201 template <
typename T,
unsigned MAXN = 0U>
1205 template <
typename T,
unsigned MAXN = 0U>
1206 inline constexpr size_t extent_v = std::extent_v<T, MAXN>;
1215 template <
typename T>
1216 using remove_extent_t =
typename std::remove_extent<T>::type;
1225 template <
typename T>
1226 using remove_all_extents_t =
typename std::remove_all_extents<T>::type;
1232 template <
typename T>
struct rank : std::rank<T> {};
1235 template <
typename T>
1236 inline constexpr size_t rank_v = std::rank_v<T>;
1242 template <
typename T>
struct decay : std::decay<T> {};
1245 template <
typename T>
1246 using decay_t =
typename std::decay<T>::type;
1252 template<
typename TBase,
typename TDerived>
struct is_base_of : std::is_base_of<TBase, TDerived> {};
1255 template <
typename TBase,
typename TDerived>
1256 inline constexpr bool is_base_of_v = std::is_base_of_v<TBase, TDerived>;
1261 template <
typename T>
struct is_class : std::is_class<T>{};
1264 template <
typename T>
1273 template <
typename T>
1274 using add_lvalue_reference_t =
typename std::add_lvalue_reference<T>::type;
1280 template <
typename T>
struct add_rvalue_reference : std::add_rvalue_reference<T> {};
1284 template <
typename T>
1285 using add_rvalue_reference_t =
typename std::add_rvalue_reference<T>::type;
1291 template <
typename T>
1292 typename std::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
1299 template <
typename T>
1300 struct is_enum : std::is_enum<T>
1305 template <
typename T>
1306 inline constexpr bool is_enum_v = etl::is_enum<T>::value;
1315 template <
typename TFrom,
typename TTo>
1316 struct is_convertible : std::is_convertible<TFrom, TTo> {};
1320 template <
typename TFrom,
typename TTo>
1321 inline constexpr bool is_convertible_v = std::is_convertible_v<TFrom, TTo>;
1328 template <>
struct alignment_of<void> : std::integral_constant<size_t, 0> {};
1329 template <>
struct alignment_of<const void> : std::integral_constant <size_t, 0> {};
1332 template <
typename T>
1333 inline constexpr size_t alignment_of_v = std::alignment_of_v<T>;
1345 template <
bool B,
typename T, T TRUE_VALUE, T FALSE_VALUE>
1348 template <
typename T, T TRUE_VALUE, T FALSE_VALUE>
1352 static const T value = TRUE_VALUE;
1355 template <
typename T, T TRUE_VALUE, T FALSE_VALUE>
1359 static const T value = FALSE_VALUE;
1366 template <
typename T,
typename T1,
typename... TRest>
1373 template <
typename T,
typename T1>
1374 struct is_one_of<T, T1>
1405 template <
typename T,
typename... TRest>
1406 inline constexpr bool is_one_of_v =
etl::is_one_of<T, TRest...>::value;
1414 template <
typename T>
1423 typedef type_t type;
1424 typedef type_t& reference;
1425 typedef const type_t& const_reference;
1426 typedef type_t* pointer;
1427 typedef const type_t* const_pointer;
1428 typedef const type_t*
const const_pointer_const;
1431 typedef type_t&& rvalue_reference;
1436 template <
typename T>
1445 typedef type_t type;
1446 typedef type_t& reference;
1447 typedef const type_t& const_reference;
1448 typedef type_t* pointer;
1449 typedef const type_t* const_pointer;
1450 typedef const type_t*
const const_pointer_const;
1453 typedef type_t&& rvalue_reference;
1458 template <
typename T>
1467 typedef type_t type;
1468 typedef type_t& reference;
1469 typedef const type_t& const_reference;
1470 typedef type_t* pointer;
1471 typedef const type_t* const_pointer;
1472 typedef const type_t*
const const_pointer_const;
1475 typedef type_t&& rvalue_reference;
1480 template <
typename T>
1489 typedef type_t type;
1490 typedef type_t& reference;
1491 typedef const type_t& const_reference;
1492 typedef type_t* pointer;
1493 typedef const type_t* const_pointer;
1494 typedef const type_t*
const const_pointer_const;
1497 typedef type_t&& rvalue_reference;
1503 template <
typename T>
1512 typedef type_t type;
1513 typedef type_t& reference;
1514 typedef const type_t& const_reference;
1515 typedef type_t* pointer;
1516 typedef const type_t* const_pointer;
1517 typedef const type_t*
const const_pointer_const;
1520 typedef type_t&& rvalue_reference;
1526 template <
typename T>
1527 using types_t =
typename types<T>::type;
1529 template <
typename T>
1530 using types_r =
typename types<T>::reference;
1532 template <
typename T>
1533 using types_cr =
typename types<T>::const_reference;
1535 template <
typename T>
1536 using types_rr =
typename types<T>::rvalue_reference;
1538 template <
typename T>
1539 using types_p =
typename types<T>::pointer;
1541 template <
typename T>
1542 using types_cp =
typename types<T>::const_pointer;
1544 template <
typename T>
1545 using types_cpc =
typename types<T>::const_pointer_const;
1555 template <
typename T>
1562 template <
typename T,
typename T1,
typename... TRest>
1566 etl::are_all_same<T, TRest...>::value;
1569 template <
typename T,
typename T1>
1570 struct are_all_same<T, T1>
1577 template <
typename T,
typename T1,
typename... TRest>
1578 inline constexpr bool are_all_same_v = are_all_same<T, T1, TRest...>::value;
1584 template <
typename...>
1589 template <
typename T1,
typename... Tn>
1590 struct conjunction<T1, Tn...> :
public etl::conditional_t<bool(T1::value), etl::conjunction<Tn...>, T1>
1594 template <
typename T>
1595 struct conjunction<T> :
public T
1601 template <
typename... T>
1602 inline constexpr bool conjunction_v = conjunction<T...>::value;
1608 template <
typename...>
1613 template <
typename T1,
typename... Tn>
1614 struct disjunction<T1, Tn...> :
public etl::conditional_t<bool(T1::value), T1, disjunction<Tn...>>
1618 template <
typename T1>
struct disjunction<T1> :
public T1
1624 template <
typename... T>
1625 inline constexpr bool disjunction_v = etl::disjunction<T...>::value;
1629#if ETL_USING_STL && ETL_USING_CPP11 && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS) && ((!defined(ARDUINO) && ETL_NOT_USING_STLPORT) || defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED))
1637 template<
typename T1,
typename T2>
1638 using is_assignable = std::is_assignable<T1, T2>;
1642 template<
typename T,
typename... TArgs>
1643 using is_constructible = std::is_constructible<T, TArgs...>;
1647 template <
typename T>
1648 using is_copy_constructible = std::is_copy_constructible<T>;
1652 template <
typename T>
1653 using is_move_constructible = std::is_move_constructible<T>;
1657#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1658 template <
typename T>
1659 using is_trivially_constructible = std::is_trivially_constructible<T>;
1661 template <
typename T>
1667#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1668 template <
typename T>
1669 using is_trivially_copy_constructible = std::is_trivially_copy_constructible<T>;
1671 template <
typename T>
1677#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1678 template <
typename T>
1679 using is_trivially_destructible = std::is_trivially_destructible<T>;
1681 template <
typename T>
1687#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1688 template <
typename T>
1689 using is_trivially_copy_assignable = std::is_trivially_copy_assignable<T>;
1691 template <
typename T>
1697#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
1698 template <
typename T>
1699 using is_trivially_copyable = std::is_trivially_copyable<T>;
1701 template <
typename T>
1705#elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS)
1713 template<
typename T1,
typename T2>
1714 struct is_assignable
1716 static ETL_CONSTANT
bool value = __is_assignable(T1, T2);
1722 template<
typename T,
typename... TArgs>
1723 struct is_constructible
1725 static ETL_CONSTANT
bool value = __is_constructible(T, TArgs...);
1730 template<
typename T,
typename TArgs =
void>
1731 struct is_constructible
1733 static ETL_CONSTANT
bool value = __is_constructible(T, TArgs);
1738 template<
typename T>
1739 struct is_constructible<T, void>
1741 static ETL_CONSTANT
bool value = __is_constructible(T);
1747 template <
typename T>
1748 struct is_copy_constructible :
public etl::is_constructible<T, typename etl::add_lvalue_reference<const T>::type>
1754 template <
typename T>
1755 struct is_move_constructible :
public etl::is_constructible<T, T>
1762 template <
typename T,
typename... TArgs>
1763 struct is_trivially_constructible
1765#if defined(ETL_COMPILER_GCC)
1766 static ETL_CONSTANT
bool value = __has_trivial_constructor(T);
1768 static ETL_CONSTANT
bool value = __is_trivially_constructible(T, TArgs...);
1774 template <
typename T,
typename TArgs =
void>
1775 struct is_trivially_constructible
1777#if defined(ETL_COMPILER_GCC)
1778 static ETL_CONSTANT
bool value = __has_trivial_constructor(T);
1780 static ETL_CONSTANT
bool value = __is_trivially_constructible(T, TArgs);
1786 template <
typename T>
1787 struct is_trivially_constructible<T, void>
1789#if defined(ETL_COMPILER_GCC)
1790 static ETL_CONSTANT
bool value = __has_trivial_constructor(T);
1792 static ETL_CONSTANT
bool value = __is_trivially_constructible(T);
1799 template <
typename T>
1800 struct is_trivially_copy_constructible :
public is_trivially_constructible<T, typename add_lvalue_reference<const T>::type>
1806 template <
typename T>
1807 struct is_trivially_destructible
1809#if defined(ETL_COMPILER_GCC)
1810 static ETL_CONSTANT
bool value = __has_trivial_destructor(T);
1812 static ETL_CONSTANT
bool value = __is_trivially_destructible(T);
1818 template <
typename T>
1819 struct is_trivially_copy_assignable
1821#if defined(ETL_COMPILER_GCC)
1822 static ETL_CONSTANT
bool value = __has_trivial_copy(T);
1824 static ETL_CONSTANT
bool value = __is_trivially_copyable(T);
1830 template <
typename T>
1831 struct is_trivially_copyable
1833#if defined(ETL_COMPILER_GCC)
1834 static ETL_CONSTANT
bool value = __has_trivial_copy(T);
1836 static ETL_CONSTANT
bool value = __is_trivially_copyable(T);
1840#elif defined(ETL_USER_DEFINED_TYPE_TRAITS) && !defined(ETL_USE_TYPE_TRAITS_BUILTINS)
1849 template <
typename T1,
1852 struct is_assignable;
1854 template <
typename T1,
typename T2>
1859 template <
typename T1,
typename T2>
1860 struct is_assignable<T1, T2, false>;
1865 template <
typename T,
bool B,
typename... TArgs>
1866 struct is_constructible_helper;
1868 template <
typename T,
typename... TArgs>
1869 struct is_constructible_helper<T, true, TArgs...> :
public etl::true_type
1873 template <
typename T,
typename... TArgs>
1874 struct is_constructible_helper<T, false, TArgs...>;
1876 template <
typename T,
typename... TArgs>
1877 struct is_constructible :
public is_constructible_helper<T, etl::is_arithmetic<T>::value || etl::is_pointer<T>::value, TArgs...>
1885 struct is_copy_constructible;
1887 template <
typename T>
1892 template <
typename T>
1893 struct is_copy_constructible<T, false>;
1898 struct is_move_constructible;
1900 template <
typename T>
1905 template <
typename T>
1906 struct is_move_constructible<T, false>;
1911 struct is_trivially_constructible;
1913 template <
typename T>
1914 struct is_trivially_constructible<T, true> :
public etl::true_type
1918 template <
typename T>
1919 struct is_trivially_constructible<T, false>;
1924 struct is_trivially_copy_constructible;
1926 template <
typename T>
1927 struct is_trivially_copy_constructible<T, true> :
public etl::true_type
1931 template <
typename T>
1932 struct is_trivially_copy_constructible<T, false>;
1937 struct is_trivially_destructible;
1939 template <
typename T>
1940 struct is_trivially_destructible<T, true> :
public etl::true_type
1944 template <
typename T>
1945 struct is_trivially_destructible<T, false>;
1950 struct is_trivially_copy_assignable;
1952 template <
typename T>
1953 struct is_trivially_copy_assignable<T, true> :
public etl::true_type
1957 template <
typename T>
1958 struct is_trivially_copy_assignable<T, false>;
1963 struct is_trivially_copyable;
1965 template <
typename T>
1970 template <
typename T>
1971 struct is_trivially_copyable<T, false>;
1982 template <
typename T1,
typename T2>
1983 struct is_assignable :
public etl::bool_constant<(etl::is_arithmetic<T1>::value || etl::is_pointer<T1>::value) && (etl::is_arithmetic<T2>::value || etl::is_pointer<T2>::value)>
1990 namespace private_type_traits
1992 template <
class,
class T,
class... Args>
1995 template <
class T,
class... Args>
1996 struct is_constructible_<void_t<decltype(T(
etl::declval<Args>()...))>, T, Args...> :
etl::true_type {};
2001 template <
class T,
class... Args>
2002 using is_constructible = private_type_traits::is_constructible_<void_t<>, T, Args...>;
2006 template <
class T>
struct is_copy_constructible :
public is_constructible<T, typename etl::add_lvalue_reference<typename etl::add_const<T>::type>::type>{};
2007 template <>
struct is_copy_constructible<void> :
public false_type{};
2008 template <>
struct is_copy_constructible<void const> :
public false_type{};
2009 template <>
struct is_copy_constructible<void volatile> :
public false_type{};
2010 template <>
struct is_copy_constructible<void const volatile> :
public false_type{};
2014 template <
typename T>
struct is_move_constructible:
public is_constructible<T, typename etl::add_rvalue_reference<T>::type>{};
2015 template <>
struct is_move_constructible<void> :
public false_type{};
2016 template <>
struct is_move_constructible<void const> :
public false_type{};
2017 template <>
struct is_move_constructible<void volatile> :
public false_type{};
2018 template <>
struct is_move_constructible<void const volatile> :
public false_type{};
2024 template <
typename T>
2031 template <
typename T>
2039 template <
typename T>
2046 template <
typename T>
2053 template <
typename T>
2060 template <
typename T>
2067 template <
typename T>
2074 template <
typename T1,
typename T2>
2076 typename etl::add_lvalue_reference<typename etl::add_const<T2>::type>::type>
2082 template <
typename T1,
typename T2>
2085 template <
typename T1,
typename T2>
2088 template<
typename T,
typename... TArgs>
2089 inline constexpr bool is_constructible_v = etl::is_constructible<T, TArgs...>::value;
2091 template<
typename T>
2094 template<
typename T>
2097 template <
typename T>
2100 template <
typename T>
2103 template <
typename T>
2106 template <
typename T>
2109 template <
typename T>
2122 template<
typename...>
2129 template <
typename T>
2130 struct common_type<T> : common_type<T, T>
2134 namespace private_common_type
2136 template <
typename T1,
typename T2>
2137 using conditional_result_t =
decltype(
false ? declval<T1>() : declval<T2>());
2139 template <
typename,
typename,
typename =
void>
2140 struct decay_conditional_result
2144 template <
typename T1,
typename T2>
2145 struct decay_conditional_result<T1, T2, void_t<conditional_result_t<T1, T2>>>
2150 template <
typename T1,
typename T2,
typename =
void>
2151 struct common_type_2_impl : decay_conditional_result<const T1&, const T2&>
2155 template <
typename T1,
typename T2>
2156 struct common_type_2_impl<T1, T2, void_t<conditional_result_t<T1, T2>>>
2157 : decay_conditional_result<T1, T2>
2164 template <
typename T1,
typename T2>
2165 struct common_type<T1, T2>
2166 :
etl::conditional<etl::is_same<T1, typename etl::decay<T1>::type>::value&& etl::is_same<T2, typename etl::decay<T2>::type>::value,
2167 private_common_type::common_type_2_impl<T1, T2>,
2168 common_type<typename etl::decay<T2>::type,
2169 typename etl::decay<T2>::type>>::type
2175 namespace private_common_type
2177 template <
typename AlwaysVoid,
typename T1,
typename T2,
typename... TRest>
2178 struct common_type_multi_impl
2182 template <
typename T1,
typename T2,
typename... TRest>
2183 struct common_type_multi_impl<void_t<typename common_type<T1, T2>::type>, T1, T2, TRest...>
2184 : common_type<typename common_type<T1, T2>::type, TRest...>
2189 template<
typename T1,
typename T2,
typename... TRest>
2190 struct common_type<T1, T2, TRest...>
2191 : private_common_type::common_type_multi_impl<void, T1, T2, TRest...>
2195 template <
typename... T>
2196 using common_type_t =
typename common_type<T...>::type;
2202 template <
typename T>
2205 typedef typename etl::conditional<
sizeof(T) ==
sizeof(
unsigned char),
unsigned char,
2206 typename etl::conditional<
sizeof(T) ==
sizeof(
unsigned short),
unsigned short,
2208 typename etl::conditional<
sizeof(T) ==
sizeof(
unsigned long),
unsigned long,
2209 unsigned long long>::type>::type>::type>::type type;
2213 template <
typename T>
2214 using unsigned_type_t =
typename unsigned_type<T>::type;
2220 template <
typename T>
2227 long long>::type>::type>::type>::type type;
2231 template <
typename T>
2232 using signed_type_t =
typename signed_type<T>::type;
2237#define ETL_IS_CHAR_TYPE(type) (etl::is_same<char, type>::value || etl::is_same<signed char, type>::value || etl::is_same<unsigned char, type>::value)
2238#define ETL_IS_NOT_CHAR_TYPE(type) (!ETL_IS_CHAR_TYPE(type))
2240#define ETL_IS_POINTER_TYPE(type) (etl::is_pointer<type>::value)
2241#define ETL_IS_NOT_POINTER_TYPE(type) (!ETL_IS_POINTER_TYPE(type))
2243#define ETL_TARGET_IS_TRIVIALLY_COPYABLE(type) (etl::is_trivially_copyable<typename etl::iterator_traits<type>::value_type>::value)
2244#define ETL_TARGET_IS_NOT_TRIVIALLY_COPYABLE(type) (!ETL_TARGET_IS_TRIVIALLY_COPYABLE(type))
integral_constant< bool, false > false_type
integral_constant specialisations
Definition: type_traits_generator.h:836
add_const
Definition: type_traits_generator.h:928
add_cv
Definition: type_traits_generator.h:978
add_pointer
Definition: type_traits_generator.h:898
add_volatile
Definition: type_traits_generator.h:958
add_rvalue_reference
Definition: type_traits_generator.h:1327
conditional
Definition: type_traits_generator.h:1160
decay
Definition: type_traits_generator.h:1242
enable_if
Definition: type_traits_generator.h:1191
extent
Definition: type_traits_generator.h:1202
integral_constant
Definition: type_traits_generator.h:832
is_arithmetic
Definition: type_traits_generator.h:1061
is_array
Definition: type_traits_generator.h:1091
is_base_of
Definition: type_traits_generator.h:1252
is_compound
Definition: type_traits_generator.h:1081
is_const
Definition: type_traits_generator.h:908
is_floating_point
Definition: type_traits_generator.h:1031
is_fundamental
Definition: type_traits_generator.h:1071
is_integral
Definition: type_traits_generator.h:1001
is_lvalue_reference
Definition: type_traits_generator.h:1121
is_rvalue_reference
Definition: type_traits_generator.h:1144
is_pointer
Definition: type_traits_generator.h:1101
is_reference
Definition: type_traits_generator.h:1111
is_same
Definition: type_traits_generator.h:1041
is_signed
Definition: type_traits_generator.h:1011
is_unsigned
Definition: type_traits_generator.h:1021
is_void
Definition: type_traits_generator.h:1051
is_volatile
Definition: type_traits_generator.h:938
make_signed
Definition: type_traits_generator.h:1171
make_unsigned
Definition: type_traits_generator.h:1181
negation
Definition: type_traits_generator.h:866
rank
Definition: type_traits_generator.h:1232
remove_all_extents
Definition: type_traits_generator.h:1222
remove_const
Definition: type_traits_generator.h:918
remove_cv
Definition: type_traits_generator.h:968
remove_cvref
Definition: type_traits_generator.h:989
remove_extent
Definition: type_traits_generator.h:1212
remove_pointer
Definition: type_traits_generator.h:888
remove_reference
Definition: type_traits_generator.h:878
remove_volatile
Definition: type_traits_generator.h:948
bitset_ext
Definition: absolute.h:38
add_lvalue_reference
Definition: type_traits_generator.h:1270
Definition: type_traits_generator.h:849
conditional_integral_constant
Definition: type_traits_generator.h:1346
conjunction
Definition: type_traits_generator.h:1984
is_class
Definition: type_traits_generator.h:1261
Definition: type_traits_generator.h:2026
Definition: type_traits_generator.h:2077
Definition: type_traits_generator.h:2033
Definition: type_traits.h:1376
Definition: type_traits_generator.h:2041
Definition: type_traits_generator.h:2062
Definition: type_traits_generator.h:2048
Definition: type_traits_generator.h:2069
Definition: type_traits_generator.h:2055
Defines one of five signed types that has the same size as T.
Definition: type_traits_generator.h:2222
size_of
Definition: type_traits_generator.h:1551
A set of templates to allow related types to be derived.
Definition: type_traits_generator.h:1416
Defines one of five unsigned types that has the same size as T.
Definition: type_traits_generator.h:2204
void add_pointer(const volatile void *value, TIString &str, const etl::basic_format_spec< TIString > &format, const bool append)
Helper function for pointers.
Definition: to_string_helper.h:442