constexpr, template aliases and inline variables

This commit is contained in:
John Wellbelove 2020-11-30 12:56:46 +00:00
parent b40431f998
commit 6144794221
24 changed files with 1051 additions and 158 deletions

View File

@ -39,7 +39,7 @@ namespace etl
// For signed types.
//***************************************************************************
template <typename T>
typename etl::enable_if<etl::is_signed<T>::value, T>::type
ETL_CONSTEXPR typename etl::enable_if<etl::is_signed<T>::value, T>::type
absolute(T value)
{
return (value < T(0)) ? -value : value;
@ -49,7 +49,7 @@ namespace etl
// For unsigned types.
//***************************************************************************
template <typename T>
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
ETL_CONSTEXPR typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
absolute(T value)
{
return value;

View File

@ -48,8 +48,13 @@ namespace etl
template <const size_t NV, const size_t KV>
struct combinations
{
static const size_t value = etl::permutations<NV, KV>::value / etl::factorial<KV>::value;
static ETL_CONSTANT size_t value = etl::permutations<NV, KV>::value / etl::factorial<KV>::value;
};
#if ETL_CPP17_SUPPORTED
template <size_t NV, size_t KV>
inline constexpr size_t combinations_v = combinations<NV, KV>::value;
#endif
}
#endif

View File

@ -118,7 +118,7 @@ namespace etl
/// Create from function (Compile time).
//*************************************************************************
template <TReturn(*Method)(TParams...)>
static delegate create()
ETL_CONSTEXPR14 static delegate create()
{
return delegate(ETL_NULLPTR, function_stub<Method>);
}
@ -127,7 +127,7 @@ namespace etl
/// Create from Lambda or Functor.
//*************************************************************************
template <typename TLambda, typename = typename etl::enable_if<etl::is_class<TLambda>::value, void>::type>
static delegate create(const TLambda& instance)
ETL_CONSTEXPR14 static delegate create(const TLambda& instance)
{
return delegate((void*)(&instance), lambda_stub<TLambda>);
}
@ -136,7 +136,7 @@ namespace etl
/// Create from instance method (Run time).
//*************************************************************************
template <typename T, TReturn(T::*Method)(TParams...)>
static delegate create(T& instance)
ETL_CONSTEXPR14 static delegate create(T& instance)
{
return delegate((void*)(&instance), method_stub<T, Method>);
}
@ -152,7 +152,7 @@ namespace etl
/// Create from const instance method (Run time).
//*************************************************************************
template <typename T, TReturn(T::*Method)(TParams...) const>
static delegate create(const T& instance)
ETL_CONSTEXPR14 static delegate create(const T& instance)
{
return delegate((void*)(&instance), const_method_stub<T, Method>);
}
@ -161,13 +161,13 @@ namespace etl
/// Disable create from rvalue instance method (Run time).
//*************************************************************************
template <typename T, TReturn(T::*Method)(TParams...) const>
static delegate create(T&& instance) = delete;
ETL_CONSTEXPR14 static delegate create(T&& instance) = delete;
//*************************************************************************
/// Create from instance method (Compile time).
//*************************************************************************
template <typename T, T& Instance, TReturn(T::*Method)(TParams...)>
static delegate create()
ETL_CONSTEXPR14 static delegate create()
{
return delegate(method_instance_stub<T, Instance, Method>);
}
@ -176,7 +176,7 @@ namespace etl
/// Create from const instance method (Compile time).
//*************************************************************************
template <typename T, T const& Instance, TReturn(T::*Method)(TParams...) const>
static delegate create()
ETL_CONSTEXPR14 static delegate create()
{
return delegate(const_method_instance_stub<T, Instance, Method>);
}
@ -187,7 +187,7 @@ namespace etl
/// At the time of writing, GCC appears to have trouble with this.
//*************************************************************************
template <typename T, T& Instance>
static delegate create()
ETL_CONSTEXPR14 static delegate create()
{
return delegate(operator_instance_stub<T, Instance>);
}
@ -288,7 +288,7 @@ namespace etl
//*************************************************************************
/// Constructs a delegate from an object and stub.
//*************************************************************************
delegate(void* object, stub_type stub)
ETL_CONSTEXPR14 delegate(void* object, stub_type stub)
{
invocation.object = object;
invocation.stub = stub;
@ -297,7 +297,7 @@ namespace etl
//*************************************************************************
/// Constructs a delegate from a stub.
//*************************************************************************
delegate(stub_type stub)
ETL_CONSTEXPR14 delegate(stub_type stub)
{
invocation.object = ETL_NULLPTR;
invocation.stub = stub;
@ -306,7 +306,7 @@ namespace etl
//*************************************************************************
/// Assign from an object and stub.
//*************************************************************************
void assign(void* object, stub_type stub)
ETL_CONSTEXPR14 void assign(void* object, stub_type stub)
{
invocation.object = object;
invocation.stub = stub;

View File

@ -49,7 +49,7 @@ namespace etl
template <size_t N>
struct factorial
{
static const size_t value = N * factorial<N - 1>::value;
static ETL_CONSTANT size_t value = N * factorial<N - 1>::value;
};
//***************************************************************************
@ -58,8 +58,13 @@ namespace etl
template <>
struct factorial<0>
{
static const size_t value = 1;
static ETL_CONSTANT size_t value = 1;
};
#if ETL_CPP17_SUPPORTED
template <size_t N>
inline constexpr size_t factorial_v = factorial<N>::value;
#endif
}
#endif

View File

@ -49,7 +49,7 @@ namespace etl
template <size_t N>
struct fibonacci
{
static const size_t value = fibonacci<N - 1>::value + fibonacci<N - 2>::value;
static ETL_CONSTANT size_t value = fibonacci<N - 1>::value + fibonacci<N - 2>::value;
};
//***************************************************************************
@ -58,7 +58,7 @@ namespace etl
template <>
struct fibonacci<1>
{
static const size_t value = 1;
static ETL_CONSTANT size_t value = 1;
};
//***************************************************************************
@ -67,8 +67,13 @@ namespace etl
template <>
struct fibonacci<0>
{
static const size_t value = 0;
static ETL_CONSTANT size_t value = 0;
};
#if ETL_CPP17_SUPPORTED
template <size_t N>
inline constexpr size_t fibonacci_v = fibonacci<N>::value;
#endif
}
#endif

View File

@ -770,7 +770,7 @@ namespace etl
/// These require compiler specific intrinsics.
#if ETL_CPP11_SUPPORTED && !defined(ETL_COMPILER_ARM5)
template <typename T> struct alignment_of : integral_constant<size_t, alignof(T)> { };
#elif ETL_COMPILER_MICROSOFT
#elif defined(ETL_COMPILER_MICROSOFT)
template <typename T> struct alignment_of : integral_constant<size_t, size_t(__alignof(T))> {};
#elif defined(ETL_COMPILER_IAR) || defined(ETL_COMPILER_TI)
template <typename T> struct alignment_of : integral_constant<size_t, size_t(__ALIGNOF__(T))> {};

View File

@ -109,6 +109,17 @@ namespace etl
size = etl::size_of<type>::value
};
};
#if ETL_CPP14_SUPPORTED
template <typename... T>
using largest_type_t = typename largest_type<T...>::type;
#endif
#if ETL_CPP17_SUPPORTED
template <typename... T>
constexpr size_t largest_type_v = largest_type<T...>::size;
#endif
#else
//***************************************************************************
/// Template to determine the largest type and size.
@ -195,6 +206,12 @@ namespace etl
value = etl::alignment_of<type>::value
};
};
#if ETL_CPP17_SUPPORTED
template <typename... T>
inline constexpr size_t largest_alignment_v = largest_alignment<T...>::value;
#endif
#else
//***************************************************************************
/// Template to determine the largest alignment.
@ -254,6 +271,11 @@ namespace etl
typedef typename etl::smallest_int_for_bits<etl::integral_limits<typename etl::make_signed<T>::type>::bits + 1>::type type;
};
#if ETL_CPP14_SUPPORTED
template <typename T>
using larger_int_type_t = typename larger_int_type<T>::type;
#endif
//***************************************************************************
/// Defines a type that is as larger or larger than the specified type.
/// Will return the specified type is there is not a larger type.
@ -267,6 +289,11 @@ namespace etl
typedef typename etl::smallest_uint_for_bits<etl::integral_limits<typename etl::make_unsigned<T>::type>::bits + 1>::type type;
};
#if ETL_CPP14_SUPPORTED
template <typename T>
using larger_uint_type_t = typename larger_uint_type<T>::type;
#endif
//***************************************************************************
/// Defines a type that is as larger or larger than the specified type.
/// Will return the specified type is there is not a larger type.
@ -292,6 +319,11 @@ namespace etl
typedef typename etl::smallest_int_for_bits<etl::integral_limits<T>::bits + 1>::type type;
};
#if ETL_CPP14_SUPPORTED
template <typename T>
using larger_type_t = typename larger_type<T>::type;
#endif
#if ETL_CPP11_SUPPORTED && !defined(ETL_LARGEST_FORCE_CPP03)
//***************************************************************************
/// Template to determine the largest type, size and alignment.
@ -309,6 +341,12 @@ namespace etl
alignment = etl::largest_alignment<T...>::value
};
};
#if ETL_CPP14_SUPPORTED
template <typename... T>
using largest_t = typename largest<T...>::type;
#endif
#else
//***************************************************************************
/// Template to determine the largest type, size and alignment.

View File

@ -125,47 +125,47 @@ namespace etl
{
public:
static const bool is_specialized = true;
static const bool is_integer = true;
static const bool is_exact = true;
static const int max_digits10 = 0;
static const int radix = 2;
static const int min_exponent = 0;
static const int min_exponent10 = 0;
static const int max_exponent = 0;
static const int max_exponent10 = 0;
static const bool has_infinity = false;
static const bool has_quiet_NaN = false;
static const bool has_signaling_NaN = false;
static const bool has_denorm_loss = false;
static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool traps = false;
static const bool tinyness_before = false;
static const float_denorm_style has_denorm = denorm_absent;
static const float_round_style round_style = round_toward_zero;
static ETL_CONSTANT bool is_specialized = true;
static ETL_CONSTANT bool is_integer = true;
static ETL_CONSTANT bool is_exact = true;
static ETL_CONSTANT int max_digits10 = 0;
static ETL_CONSTANT int radix = 2;
static ETL_CONSTANT int min_exponent = 0;
static ETL_CONSTANT int min_exponent10 = 0;
static ETL_CONSTANT int max_exponent = 0;
static ETL_CONSTANT int max_exponent10 = 0;
static ETL_CONSTANT bool has_infinity = false;
static ETL_CONSTANT bool has_quiet_NaN = false;
static ETL_CONSTANT bool has_signaling_NaN = false;
static ETL_CONSTANT bool has_denorm_loss = false;
static ETL_CONSTANT bool is_iec559 = false;
static ETL_CONSTANT bool is_bounded = true;
static ETL_CONSTANT bool traps = false;
static ETL_CONSTANT bool tinyness_before = false;
static ETL_CONSTANT float_denorm_style has_denorm = denorm_absent;
static ETL_CONSTANT float_round_style round_style = round_toward_zero;
};
class etl_floating_point_limits
{
public:
static const bool is_specialized = true;
static const bool is_signed = true;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 2;
static const bool has_infinity = true;
static const bool has_quiet_NaN = ETL_HAS_NAN;
static const bool has_signaling_NaN = ETL_HAS_NAN;
static const bool has_denorm_loss = false;
static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = false;
static const bool traps = false;
static const bool tinyness_before = false;
static const float_denorm_style has_denorm = denorm_indeterminate;
static const float_round_style round_style = round_indeterminate;
static ETL_CONSTANT bool is_specialized = true;
static ETL_CONSTANT bool is_signed = true;
static ETL_CONSTANT bool is_integer = false;
static ETL_CONSTANT bool is_exact = false;
static ETL_CONSTANT int radix = 2;
static ETL_CONSTANT bool has_infinity = true;
static ETL_CONSTANT bool has_quiet_NaN = ETL_HAS_NAN;
static ETL_CONSTANT bool has_signaling_NaN = ETL_HAS_NAN;
static ETL_CONSTANT bool has_denorm_loss = false;
static ETL_CONSTANT bool is_iec559 = false;
static ETL_CONSTANT bool is_bounded = true;
static ETL_CONSTANT bool is_modulo = false;
static ETL_CONSTANT bool traps = false;
static ETL_CONSTANT bool tinyness_before = false;
static ETL_CONSTANT float_denorm_style has_denorm = denorm_indeterminate;
static ETL_CONSTANT float_round_style round_style = round_indeterminate;
static float round_error() { return float(0.5); }
};
@ -191,10 +191,10 @@ namespace etl
{
public:
static const int digits = 1;
static const int digits10 = 0;
static const bool is_signed = false;
static const bool is_modulo = false;
static ETL_CONSTANT int digits = 1;
static ETL_CONSTANT int digits10 = 0;
static ETL_CONSTANT bool is_signed = false;
static ETL_CONSTANT bool is_modulo = false;
static bool min() { return false; }
static bool max() { return true; }
@ -214,10 +214,10 @@ namespace etl
{
public:
static const int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed<char>::value ? 1 : 0);
static const int digits10 = ETL_LOG10_OF_2(digits);
static const bool is_signed = etl::is_signed<char>::value;
static const bool is_modulo = false;
static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed<char>::value ? 1 : 0);
static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
static ETL_CONSTANT bool is_signed = etl::is_signed<char>::value;
static ETL_CONSTANT bool is_modulo = false;
static char min() { return char(CHAR_MIN); }
static char max() { return char(CHAR_MAX); }
@ -237,10 +237,10 @@ namespace etl
{
public:
static const int digits = (CHAR_BIT * sizeof(unsigned char)) - (etl::is_signed<unsigned char>::value ? 1 : 0);
static const int digits10 = ETL_LOG10_OF_2(digits);
static const bool is_signed = false;
static const bool is_modulo = true;
static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned char)) - (etl::is_signed<unsigned char>::value ? 1 : 0);
static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
static ETL_CONSTANT bool is_signed = false;
static ETL_CONSTANT bool is_modulo = true;
static unsigned char min() { return 0U; }
static unsigned char max() { return UCHAR_MAX; }
@ -260,10 +260,10 @@ namespace etl
{
public:
static const int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed<char>::value ? 1 : 0);
static const int digits10 = ETL_LOG10_OF_2(digits);
static const bool is_signed = true;
static const bool is_modulo = false;
static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed<char>::value ? 1 : 0);
static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
static ETL_CONSTANT bool is_signed = true;
static ETL_CONSTANT bool is_modulo = false;
static signed char min() { return SCHAR_MIN; }
static signed char max() { return SCHAR_MAX; }
@ -284,10 +284,10 @@ namespace etl
{
public:
static const int digits = (CHAR_BIT * sizeof(char16_t)) - (etl::is_signed<char16_t>::value ? 1 : 0);
static const int digits10 = ETL_LOG10_OF_2(digits);
static const bool is_signed = false;
static const bool is_modulo = true;
static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char16_t)) - (etl::is_signed<char16_t>::value ? 1 : 0);
static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
static ETL_CONSTANT bool is_signed = false;
static ETL_CONSTANT bool is_modulo = true;
static char16_t min() { return 0U; }
static char16_t max() { return UINT_LEAST16_MAX; }
@ -307,10 +307,10 @@ namespace etl
{
public:
static const int digits = (CHAR_BIT * sizeof(char32_t)) - (etl::is_signed<char32_t>::value ? 1 : 0);
static const int digits10 = ETL_LOG10_OF_2(digits);
static const bool is_signed = false;
static const bool is_modulo = true;
static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char32_t)) - (etl::is_signed<char32_t>::value ? 1 : 0);
static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
static ETL_CONSTANT bool is_signed = false;
static ETL_CONSTANT bool is_modulo = true;
static char32_t min() { return 0U; }
static char32_t max() { return UINT_LEAST32_MAX; }
@ -332,10 +332,10 @@ namespace etl
{
public:
static const int digits = (CHAR_BIT * sizeof(wchar_t)) - (etl::is_signed<wchar_t>::value ? 1 : 0);
static const int digits10 = ETL_LOG10_OF_2(digits);
static const bool is_signed = etl::is_signed<wchar_t>::value;
static const bool is_modulo = etl::is_unsigned<wchar_t>::value;
static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(wchar_t)) - (etl::is_signed<wchar_t>::value ? 1 : 0);
static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
static ETL_CONSTANT bool is_signed = etl::is_signed<wchar_t>::value;
static ETL_CONSTANT bool is_modulo = etl::is_unsigned<wchar_t>::value;
static wchar_t min() { return WCHAR_MIN; }
static wchar_t max() { return WCHAR_MAX; }
@ -355,10 +355,10 @@ namespace etl
{
public:
static const int digits = (CHAR_BIT * sizeof(short)) - (etl::is_signed<short>::value ? 1 : 0);
static const int digits10 = ETL_LOG10_OF_2(digits);
static const bool is_signed = true;
static const bool is_modulo = false;
static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(short)) - (etl::is_signed<short>::value ? 1 : 0);
static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
static ETL_CONSTANT bool is_signed = true;
static ETL_CONSTANT bool is_modulo = false;
static short min() { return SHRT_MIN; }
static short max() { return SHRT_MAX; }
@ -378,10 +378,10 @@ namespace etl
{
public:
static const int digits = (CHAR_BIT * sizeof(unsigned short)) - (etl::is_signed<unsigned short>::value ? 1 : 0);
static const int digits10 = ETL_LOG10_OF_2(digits);
static const bool is_signed = false;
static const bool is_modulo = true;
static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned short)) - (etl::is_signed<unsigned short>::value ? 1 : 0);
static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
static ETL_CONSTANT bool is_signed = false;
static ETL_CONSTANT bool is_modulo = true;
static unsigned short min() { return 0U; }
static unsigned short max() { return USHRT_MAX; }
@ -402,10 +402,10 @@ namespace etl
{
public:
static const int digits = (CHAR_BIT * sizeof(int)) - (etl::is_signed<int>::value ? 1 : 0);
static const int digits10 = ETL_LOG10_OF_2(digits);
static const bool is_signed = true;
static const bool is_modulo = false;
static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(int)) - (etl::is_signed<int>::value ? 1 : 0);
static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
static ETL_CONSTANT bool is_signed = true;
static ETL_CONSTANT bool is_modulo = false;
static int min() { return INT_MIN; }
static int max() { return INT_MAX; }
@ -425,10 +425,10 @@ namespace etl
{
public:
static const int digits = (CHAR_BIT * sizeof(unsigned int)) - (etl::is_signed<unsigned int>::value ? 1 : 0);
static const int digits10 = ETL_LOG10_OF_2(digits);
static const bool is_signed = false;
static const bool is_modulo = true;
static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned int)) - (etl::is_signed<unsigned int>::value ? 1 : 0);
static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
static ETL_CONSTANT bool is_signed = false;
static ETL_CONSTANT bool is_modulo = true;
static unsigned int min() { return 0U; }
static unsigned int max() { return UINT_MAX; }
@ -448,10 +448,10 @@ namespace etl
{
public:
static const int digits = (CHAR_BIT * sizeof(long)) - (etl::is_signed<long>::value ? 1 : 0);
static const int digits10 = ETL_LOG10_OF_2(digits);
static const bool is_signed = true;
static const bool is_modulo = false;
static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(long)) - (etl::is_signed<long>::value ? 1 : 0);
static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
static ETL_CONSTANT bool is_signed = true;
static ETL_CONSTANT bool is_modulo = false;
static long min() { return LONG_MIN; }
static long max() { return LONG_MAX; }
@ -471,10 +471,10 @@ namespace etl
{
public:
static const int digits = (CHAR_BIT * sizeof(unsigned long)) - (etl::is_signed<unsigned long>::value ? 1 : 0);
static const int digits10 = ETL_LOG10_OF_2(digits);
static const bool is_signed = false;
static const bool is_modulo = true;
static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned long)) - (etl::is_signed<unsigned long>::value ? 1 : 0);
static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
static ETL_CONSTANT bool is_signed = false;
static ETL_CONSTANT bool is_modulo = true;
static unsigned long min() { return 0U; }
static unsigned long max() { return ULONG_MAX; }
@ -494,10 +494,10 @@ namespace etl
{
public:
static const int digits = (CHAR_BIT * sizeof(long long)) - (etl::is_signed<long long>::value ? 1 : 0);
static const int digits10 = ETL_LOG10_OF_2(digits);
static const bool is_signed = true;
static const bool is_modulo = false;
static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(long long)) - (etl::is_signed<long long>::value ? 1 : 0);
static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
static ETL_CONSTANT bool is_signed = true;
static ETL_CONSTANT bool is_modulo = false;
static long long min() { return LLONG_MIN; }
static long long max() { return LLONG_MAX; }
@ -517,10 +517,10 @@ namespace etl
{
public:
static const int digits = (CHAR_BIT * sizeof(unsigned long long)) - (etl::is_signed<unsigned long long>::value ? 1 : 0);
static const int digits10 = ETL_LOG10_OF_2(digits);
static const bool is_signed = false;
static const bool is_modulo = true;
static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned long long)) - (etl::is_signed<unsigned long long>::value ? 1 : 0);
static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
static ETL_CONSTANT bool is_signed = false;
static ETL_CONSTANT bool is_modulo = true;
static unsigned long long min() { return 0U; }
static unsigned long long max() { return ULLONG_MAX; }
@ -549,14 +549,14 @@ namespace etl
static float quiet_NaN() { return ETL_NANF; }
static float signaling_NaN() { return ETL_NANF; }
static const int digits = FLT_MANT_DIG;
static const int digits10 = FLT_DIG;
static const int max_digits10 = ETL_LOG10_OF_2(FLT_MANT_DIG) + 2;
static ETL_CONSTANT int digits = FLT_MANT_DIG;
static ETL_CONSTANT int digits10 = FLT_DIG;
static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(FLT_MANT_DIG) + 2;
static const int min_exponent = FLT_MIN_EXP;
static const int min_exponent10 = FLT_MIN_10_EXP;
static const int max_exponent = FLT_MAX_EXP;
static const int max_exponent10 = FLT_MAX_10_EXP;
static ETL_CONSTANT int min_exponent = FLT_MIN_EXP;
static ETL_CONSTANT int min_exponent10 = FLT_MIN_10_EXP;
static ETL_CONSTANT int max_exponent = FLT_MAX_EXP;
static ETL_CONSTANT int max_exponent10 = FLT_MAX_10_EXP;
};
//***************************************************************************
@ -575,14 +575,14 @@ namespace etl
static double quiet_NaN() { return ETL_NAN; }
static double signaling_NaN() { return ETL_NAN; }
static const int digits = DBL_MANT_DIG;
static const int digits10 = DBL_DIG;
static const int max_digits10 = ETL_LOG10_OF_2(DBL_MANT_DIG) + 2;
static ETL_CONSTANT int digits = DBL_MANT_DIG;
static ETL_CONSTANT int digits10 = DBL_DIG;
static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(DBL_MANT_DIG) + 2;
static const int min_exponent = DBL_MIN_EXP;
static const int min_exponent10 = DBL_MIN_10_EXP;
static const int max_exponent = DBL_MAX_EXP;
static const int max_exponent10 = DBL_MAX_10_EXP;
static ETL_CONSTANT int min_exponent = DBL_MIN_EXP;
static ETL_CONSTANT int min_exponent10 = DBL_MIN_10_EXP;
static ETL_CONSTANT int max_exponent = DBL_MAX_EXP;
static ETL_CONSTANT int max_exponent10 = DBL_MAX_10_EXP;
};
//***************************************************************************
@ -601,14 +601,14 @@ namespace etl
static long double quiet_NaN() { return ETL_NANL; }
static long double signaling_NaN() { return ETL_NANL; }
static const int digits = LDBL_MANT_DIG;
static const int digits10 = LDBL_DIG;
static const int max_digits10 = ETL_LOG10_OF_2(LDBL_MANT_DIG) + 2;
static ETL_CONSTANT int digits = LDBL_MANT_DIG;
static ETL_CONSTANT int digits10 = LDBL_DIG;
static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(LDBL_MANT_DIG) + 2;
static const int min_exponent = LDBL_MIN_EXP;
static const int min_exponent10 = LDBL_MIN_10_EXP;
static const int max_exponent = LDBL_MAX_EXP;
static const int max_exponent10 = LDBL_MAX_10_EXP;
static ETL_CONSTANT int min_exponent = LDBL_MIN_EXP;
static ETL_CONSTANT int min_exponent10 = LDBL_MIN_10_EXP;
static ETL_CONSTANT int max_exponent = LDBL_MAX_EXP;
static ETL_CONSTANT int max_exponent10 = LDBL_MAX_10_EXP;
};
}

View File

@ -51,7 +51,7 @@ namespace etl
///\tparam NV The number to find the log of.
///\tparam BASE The base of the log.
//***************************************************************************
template <const size_t NV, const size_t BASE>
template <size_t NV, size_t BASE>
struct log
{
enum value_type
@ -64,7 +64,7 @@ namespace etl
//***************************************************************************
// Specialisation for N = 1
//***************************************************************************
template <const size_t BASE>
template <size_t BASE>
struct log<1, BASE>
{
enum value_type
@ -76,7 +76,7 @@ namespace etl
//***************************************************************************
// Specialisation for N = 0
//***************************************************************************
template <const size_t BASE>
template <size_t BASE>
struct log<0, BASE>
{
enum value_type
@ -85,6 +85,11 @@ namespace etl
};
};
#if ETL_CPP17_SUPPORTED
template <size_t NV, size_t BASE>
inline constexpr size_t log_v = log<NV, BASE>::value;
#endif
//***************************************************************************
///\ingroup log
/// Calculates base 2 logs.
@ -98,6 +103,11 @@ namespace etl
};
};
#if ETL_CPP17_SUPPORTED
template <size_t NV>
inline constexpr size_t log2_v = log2<NV>::value;
#endif
//***************************************************************************
///\ingroup log
/// Calculates base 10 logs.
@ -110,6 +120,11 @@ namespace etl
value = log<NV, 10>::value
};
};
#if ETL_CPP17_SUPPORTED
template <size_t NV>
inline constexpr size_t log10_v = log10<NV>::value;
#endif
}
#endif

View File

@ -39,7 +39,8 @@ namespace etl
// For signed types.
//***************************************************************************
template <typename T>
typename etl::enable_if<etl::is_signed<T>::value, bool>::type
ETL_CONSTEXPR
typename etl::enable_if<etl::is_signed<T>::value, bool>::type
is_negative(const T value)
{
return (value < T(0));
@ -49,6 +50,7 @@ namespace etl
// For unsigned types.
//***************************************************************************
template <typename T>
ETL_CONSTEXPR
typename etl::enable_if<etl::is_unsigned<T>::value, bool>::type
is_negative(const T)
{

View File

@ -46,7 +46,7 @@ namespace etl
template <const size_t NV, const size_t KV>
struct permutations
{
static const size_t value = NV * permutations<NV - 1, KV - 1>::value;
static ETL_CONSTANT size_t value = NV * permutations<NV - 1, KV - 1>::value;
};
//***************************************************************************
@ -56,8 +56,13 @@ namespace etl
template <const size_t NV>
struct permutations<NV, 0>
{
static const size_t value = 1;
static ETL_CONSTANT size_t value = 1;
};
#if ETL_CPP17_SUPPORTED
template <size_t NV, size_t KV>
inline constexpr size_t permutations_v = permutations<NV, KV>::value;
#endif
}
#endif

View File

@ -170,11 +170,13 @@ SOFTWARE.
#define ETL_IF_CONSTEXPR constexpr
#define ETL_NODISCARD [[nodiscard]]
#define ETL_FALLTHROUGH [[fallthrough]]
#define ETL_INLINE_VAR inline
#else
#define ETL_CONSTEXPR17
#define ETL_IF_CONSTEXPR
#define ETL_NODISCARD
#define ETL_FALLTHROUGH
#define ETL_INLINE_VAR
#endif
// C++20

View File

@ -60,7 +60,7 @@ namespace etl
template <const size_t NV, const size_t POWER>
struct power
{
static const private_power::type value = NV * power<NV, POWER - 1>::value;
static ETL_CONSTANT private_power::type value = NV * power<NV, POWER - 1>::value;
};
//***************************************************************************
@ -71,9 +71,14 @@ namespace etl
template <const size_t NV>
struct power<NV, 0>
{
static const private_power::type value = 1;
static ETL_CONSTANT private_power::type value = 1;
};
#if ETL_CPP17_SUPPORTED
template <size_t NV, size_t POWER>
inline constexpr size_t power_v = power<NV, POWER>::value;
#endif
//***************************************************************************
///\ingroup power
/// Calculates the rounded up power of 2.
@ -101,6 +106,11 @@ namespace etl
};
};
#if ETL_CPP17_SUPPORTED
template <size_t NV>
inline constexpr size_t power_of_2_round_up_v = power_of_2_round_up<NV>::value;
#endif
//***************************************************************************
///\ingroup power
/// Calculates the rounded down power of 2.
@ -156,6 +166,11 @@ namespace etl
};
};
#if ETL_CPP17_SUPPORTED
template <size_t NV>
inline constexpr size_t power_of_2_round_down_v = power_of_2_round_down<NV>::value;
#endif
//***************************************************************************
///\ingroup power
/// Checks if N is a power of 2.
@ -163,7 +178,7 @@ namespace etl
template <const size_t NV>
struct is_power_of_2
{
static const bool value = (NV & (NV - 1)) == 0;
static ETL_CONSTANT bool value = (NV & (NV - 1)) == 0;
};
//***************************************************************************
@ -174,7 +189,7 @@ namespace etl
template <>
struct is_power_of_2<0>
{
static const bool value = false;
static ETL_CONSTANT bool value = false;
};
//***************************************************************************
@ -185,8 +200,13 @@ namespace etl
template <>
struct is_power_of_2<1>
{
static const bool value = false;
static ETL_CONSTANT bool value = false;
};
#if ETL_CPP17_SUPPORTED
template <size_t NV>
inline constexpr size_t is_power_of_2_v = is_power_of_2<NV>::value;
#endif
}
#endif

View File

@ -41,8 +41,8 @@ namespace etl
template <const size_t NUM, const size_t DEN = 1>
struct ratio
{
static const intmax_t num = NUM;
static const intmax_t den = DEN;
static ETL_CONSTANT intmax_t num = NUM;
static ETL_CONSTANT intmax_t den = DEN;
};
#if INT_MAX > INT32_MAX

View File

@ -109,6 +109,17 @@ namespace etl
size = etl::size_of<type>::value
};
};
#if ETL_CPP14_SUPPORTED
template <typename... T>
using smallest_type_t = typename smallest_type<T...>::type;
#endif
#if ETL_CPP17_SUPPORTED
template <typename... T>
constexpr size_t smallest_type_v = smallest_type<T...>::size;
#endif
#else
//***************************************************************************
/// Template to determine the smallest type and size.
@ -273,7 +284,7 @@ namespace etl
/// Defines 'type' which is the type of the smallest unsigned integer.
///\ingroup smallest
//***************************************************************************
template <const size_t NBITS>
template <size_t NBITS>
struct smallest_uint_for_bits
{
private:
@ -288,13 +299,18 @@ namespace etl
typedef typename private_smallest::best_fit_uint_type<TYPE_INDEX>::type type;
};
#if ETL_CPP14_SUPPORTED
template <size_t NBITS>
using smallest_uint_for_bits_t = typename smallest_uint_for_bits<NBITS>::type;
#endif
//***************************************************************************
/// Template to determine the smallest signed int type that can contain a
/// value with the specified number of bits.
/// Defines 'type' which is the type of the smallest signed integer.
///\ingroup smallest
//***************************************************************************
template <const size_t NBITS>
template <size_t NBITS>
struct smallest_int_for_bits
{
private:
@ -309,13 +325,18 @@ namespace etl
typedef typename private_smallest::best_fit_int_type<TYPE_INDEX>::type type;
};
#if ETL_CPP14_SUPPORTED
template <size_t NBITS>
using smallest_int_for_bits_t = typename smallest_int_for_bits<NBITS>::type;
#endif
//***************************************************************************
/// Template to determine the smallest unsigned int type that can contain the
/// specified unsigned value.
/// Defines 'type' which is the type of the smallest unsigned integer.
///\ingroup smallest
//***************************************************************************
template <const uintmax_t VALUE>
template <uintmax_t VALUE>
struct smallest_uint_for_value
{
private:
@ -330,6 +351,11 @@ namespace etl
typedef typename private_smallest::best_fit_uint_type<TYPE_INDEX>::type type;
};
#if ETL_CPP14_SUPPORTED
template <uintmax_t VALUE>
using smallest_uint_for_value_t = typename smallest_uint_for_value<VALUE>::type;
#endif
//***************************************************************************
/// Template to determine the smallest int type that can contain the
/// specified signed value.
@ -350,6 +376,11 @@ namespace etl
typedef typename private_smallest::best_fit_int_type<TYPE_INDEX>::type type;
};
#if ETL_CPP14_SUPPORTED
template <intmax_t VALUE>
using smallest_int_for_value_t = typename smallest_int_for_value<VALUE>::type;
#endif
}
#endif

View File

@ -42,7 +42,7 @@ namespace etl
//***************************************************************************
/// Calculates the smallest value that, when squared, will be not greater than VALUE.
//***************************************************************************
template <const size_t VALUE, const size_t I = 1>
template <size_t VALUE, size_t I = 1>
struct sqrt
{
typedef typename etl::conditional<((I * I) > VALUE),
@ -59,6 +59,11 @@ namespace etl
};
#endif
};
#if ETL_CPP17_SUPPORTED
template <size_t VALUE, size_t I = 1>
inline constexpr size_t sqrt_v = sqrt<VALUE, I>::value;
#endif
}
#endif

View File

@ -117,8 +117,10 @@ namespace etl
static_assert(!(etl::is_same<nulltype, type>::value), "Invalid id");
};
#if ETL_CPP14_SUPPORTED
template <int ID>
using type_from_id_t = typename type_from_id<ID>::type;
#endif
private:
@ -211,9 +213,11 @@ namespace etl
static_assert(!etl::is_same<type, nulltype>::value, "Type match not found");
};
#if ETL_CPP14_SUPPORTED
// Template alias.
template <typename T>
using TypeFromType_t = typename type_from_type<T>::type;
using type_from_type_t = typename type_from_type<T>::type;
#endif
};
#else

View File

@ -82,8 +82,10 @@ namespace etl
using type = typename type_select_helper<ID, 0, TTypes...>::type;
};
#if ETL_CPP14_SUPPORTED
template <size_t ID>
using select_t = typename select<ID>::type;
#endif
};
#else

View File

@ -41,7 +41,7 @@ SOFTWARE.
#endif
#ifdef ETL_COMPILER_GCC
#pragma GCC diagnostic ignored "-Wno-deprecated"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
void f(int)

View File

@ -172,6 +172,20 @@ namespace
CHECK_THROW(d(), etl::delegate_uninitialised);
}
SUITE(test_constexpr_delegate)
{
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_is_valid_false)
{
constexpr etl::delegate<void(void)> d;
CHECK(!d.is_valid());
CHECK(!d);
CHECK_THROW(d(), etl::delegate_uninitialised);
}
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_is_valid_true)
{
@ -192,6 +206,16 @@ namespace
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_free_void_constexpr)
{
constexpr auto d = etl::delegate<void(void)>::create<free_void>();
d();
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_free_int)
{
@ -203,6 +227,17 @@ namespace
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_free_int_constexpr)
{
constexpr auto d = etl::delegate<void(int, int)>::create<free_int>();
d(VALUE1, VALUE2);
CHECK(function_called);
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_free_reference)
{
@ -217,6 +252,20 @@ namespace
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_free_reference_constexpr)
{
constexpr etl::delegate<void(const Data&, int)> d = etl::delegate<void(const Data&, int)>::create<free_reference>();
Data data;
data.d = VALUE1;
d(data, VALUE2);
CHECK(function_called);
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_lambda_int)
{
@ -265,6 +314,18 @@ namespace
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_operator_void_create_constexpr)
{
static Test test;
constexpr auto d = etl::delegate<void(void)>::create(test);
d();
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_operator_void_const)
{
@ -288,6 +349,16 @@ namespace
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_operator_void_compile_time_constexpr)
{
constexpr auto d = etl::delegate<void(void)>::create<Test, test_static>();
d();
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_operator_void_compile_time_const)
{
@ -297,6 +368,16 @@ namespace
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_operator_void_compile_time_const_constexpr)
{
constexpr auto d = etl::delegate<void(void)>::create<const Test, const_test_static>();
d();
CHECK(function_called);
}
#endif
//*************************************************************************
@ -325,6 +406,18 @@ namespace
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_void_constexpr)
{
static Test test;
constexpr auto d = etl::delegate<void(void)>::create<Test, &Test::member_void>(test);
d();
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_void_const)
{
@ -337,6 +430,18 @@ namespace
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_void_const_constexpr)
{
static const Test test;
constexpr auto d = etl::delegate<void(void)>::create<Test, &Test::member_void_const>(test);
d();
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_int)
{
@ -350,6 +455,19 @@ namespace
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_int_constexpr)
{
static Test test;
constexpr auto d = etl::delegate<void(int, int)>::create<Test, &Test::member_int>(test);
d(VALUE1, VALUE2);
CHECK(function_called);
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_int_const)
{
@ -363,6 +481,19 @@ namespace
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_int_const_constexpr)
{
static const Test test;
constexpr auto d = etl::delegate<void(int, int)>::create<Test, &Test::member_int_const>(test);
d(VALUE1, VALUE2);
CHECK(function_called);
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_reference)
{
@ -378,6 +509,21 @@ namespace
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_reference_constexpr)
{
static Test test;
constexpr auto d = etl::delegate<void(const Data&, int)>::create<Test, &Test::member_reference>(test);
Data data;
data.d = VALUE1;
d(data, VALUE2);
CHECK(function_called);
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_reference_const)
{
@ -393,6 +539,21 @@ namespace
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_reference_const_constexpr)
{
static const Test test;
constexpr auto d = etl::delegate<void(const Data&, int)>::create<Test, &Test::member_reference_const>(test);
Data data;
data.d = VALUE1;
d(data, VALUE2);
CHECK(function_called);
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_static)
{
@ -407,6 +568,20 @@ namespace
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_static_constexpr)
{
constexpr auto d = etl::delegate<void(const Data&, int)>::create<Test::member_static>();
Data data;
data.d = VALUE1;
d(data, VALUE2);
CHECK(function_called);
CHECK(parameter_correct);
}
#if !(defined(ETL_COMPILER_GCC) && (__GNUC__ <= 5))
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_void_compile_time)
@ -418,6 +593,16 @@ namespace
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_void_compile_time_constexpr)
{
constexpr auto d = etl::delegate<void(void)>::create<Test, test_static, &Test::member_void>();
d();
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_void_const_compile_time)
{
@ -428,6 +613,16 @@ namespace
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_void_const_compile_time_constexpr)
{
constexpr auto d = etl::delegate<void(void)>::create<Test, const_test_static, &Test::member_void_const>();
d();
CHECK(function_called);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_int_compile_time)
{
@ -439,6 +634,17 @@ namespace
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_int_compile_time_constexpr)
{
constexpr auto d = etl::delegate<void(int, int)>::create<Test, test_static, &Test::member_int>();
d(VALUE1, VALUE2);
CHECK(function_called);
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_int_const_compile_time)
{
@ -450,6 +656,17 @@ namespace
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_int_const_compile_time_constexpr)
{
constexpr auto d = etl::delegate<void(int, int)>::create<Test, const_test_static, &Test::member_int_const>();
d(VALUE1, VALUE2);
CHECK(function_called);
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_reference_compile_time)
{
@ -464,6 +681,20 @@ namespace
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_reference_compile_time_constexpr)
{
constexpr auto d = etl::delegate<void(const Data&, int)>::create<Test, test_static, &Test::member_reference>();
Data data;
data.d = VALUE1;
d(data, VALUE2);
CHECK(function_called);
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_reference_const_compile_time)
{
@ -477,6 +708,20 @@ namespace
CHECK(function_called);
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_member_reference_const_compile_time_constexpr)
{
constexpr auto d = etl::delegate<void(const Data&, int)>::create<Test, const_test_static, &Test::member_reference_const>();
Data data;
data.d = VALUE1;
d(data, VALUE2);
CHECK(function_called);
CHECK(parameter_correct);
}
#endif
//*************************************************************************
@ -493,6 +738,20 @@ namespace
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_copy_construct_constexpr)
{
static Test test;
constexpr auto d1 = etl::delegate<void(int, int)>::create<Test, &Test::member_int>(test);
constexpr auto d2(d1);
d2(VALUE1, VALUE2);
CHECK(function_called);
CHECK(parameter_correct);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_assignment)
{

View File

@ -55,6 +55,25 @@ namespace
CHECK(type);
}
//*************************************************************************
TEST(test_pod_type_vt)
{
size_t size;
bool type;
size = etl::largest_type_v<char, short, int>;
type = etl::is_same<int, etl::largest_type_t<char, short, int>>::value;
CHECK_EQUAL(sizeof(int), size);
CHECK(type);
size = etl::largest_type_v<int, char, short>;
type = etl::is_same<int, etl::largest_type_t<char, short, int>>::value;
CHECK_EQUAL(sizeof(int), size);
CHECK(type);
}
//*************************************************************************
TEST(test_non_pod_type)
{
@ -78,6 +97,29 @@ namespace
CHECK(type);
}
//*************************************************************************
TEST(test_non_pod_type_vt)
{
size_t size;
bool type;
struct S1 { char a; char b; char c; };
struct S2 { char a; short b; char c; };
struct S3 { int a; short b; char c; };
size = etl::largest_type_v<S1, S2, S3>;
type = etl::is_same<S3, etl::largest_type_t<S1, S2, S3>>::value;
CHECK_EQUAL(sizeof(S3), size);
CHECK(type);
size = etl::largest_type_v<S2, S3, S1>;
type = etl::is_same<S3, etl::largest_type_t<S2, S3, S1>>::value;
CHECK_EQUAL(sizeof(S3), size);
CHECK(type);
}
//*************************************************************************
TEST(test_pod_alignment)
{
@ -86,6 +128,14 @@ namespace
CHECK_EQUAL(std::alignment_of<double>::value, size);
}
//*************************************************************************
TEST(test_pod_alignment_v)
{
size_t size = etl::largest_alignment_v<char, short, int, double>;
CHECK_EQUAL(std::alignment_of<double>::value, size);
}
//*************************************************************************
TEST(test_non_pod_alignment)
{
@ -98,6 +148,18 @@ namespace
CHECK_EQUAL(std::alignment_of<S3>::value, size);
}
//*************************************************************************
TEST(test_non_pod_alignment_v)
{
struct S1 { char a; char b; char c; };
struct S2 { char a; short b; char c; };
struct S3 { int a; short b; char c; };
size_t size = etl::largest_alignment_v<S1, S2, S3>;
CHECK_EQUAL(std::alignment_of<S3>::value, size);
}
//*************************************************************************
TEST(test_larger_int_type)
{
@ -112,6 +174,20 @@ namespace
CHECK(bool(etl::is_same<etl::larger_int_type<uint64_t>::type, int64_t>::value));
}
//*************************************************************************
TEST(test_larger_int_type_t)
{
CHECK(bool(etl::is_same<etl::larger_int_type_t<int8_t>, int16_t>::value));
CHECK(bool(etl::is_same<etl::larger_int_type_t<int16_t>, int32_t>::value));
CHECK(bool(etl::is_same<etl::larger_int_type_t<int32_t>, int64_t>::value));
CHECK(bool(etl::is_same<etl::larger_int_type_t<int64_t>, int64_t>::value));
CHECK(bool(etl::is_same<etl::larger_int_type_t<uint8_t>, int16_t>::value));
CHECK(bool(etl::is_same<etl::larger_int_type_t<uint16_t>, int32_t>::value));
CHECK(bool(etl::is_same<etl::larger_int_type_t<uint32_t>, int64_t>::value));
CHECK(bool(etl::is_same<etl::larger_int_type_t<uint64_t>, int64_t>::value));
}
//*************************************************************************
TEST(test_larger_uint_type)
{
@ -126,6 +202,20 @@ namespace
CHECK(bool(etl::is_same<etl::larger_uint_type<uint64_t>::type, uint64_t>::value));
}
//*************************************************************************
TEST(test_larger_uint_type_t)
{
CHECK(bool(etl::is_same<etl::larger_uint_type_t<int8_t>, uint16_t>::value));
CHECK(bool(etl::is_same<etl::larger_uint_type_t<int16_t>, uint32_t>::value));
CHECK(bool(etl::is_same<etl::larger_uint_type_t<int32_t>, uint64_t>::value));
CHECK(bool(etl::is_same<etl::larger_uint_type_t<int64_t>, uint64_t>::value));
CHECK(bool(etl::is_same<etl::larger_uint_type_t<uint8_t>, uint16_t>::value));
CHECK(bool(etl::is_same<etl::larger_uint_type_t<uint16_t>, uint32_t>::value));
CHECK(bool(etl::is_same<etl::larger_uint_type_t<uint32_t>, uint64_t>::value));
CHECK(bool(etl::is_same<etl::larger_uint_type_t<uint64_t>, uint64_t>::value));
}
//*************************************************************************
TEST(test_larger_type)
{
@ -139,5 +229,19 @@ namespace
CHECK(bool(etl::is_same<etl::larger_type<uint32_t>::type, uint64_t>::value));
CHECK(bool(etl::is_same<etl::larger_type<uint64_t>::type, uint64_t>::value));
}
//*************************************************************************
TEST(test_larger_type_t)
{
CHECK(bool(etl::is_same<etl::larger_type_t<int8_t>, int16_t>::value));
CHECK(bool(etl::is_same<etl::larger_type_t<int16_t>, int32_t>::value));
CHECK(bool(etl::is_same<etl::larger_type_t<int32_t>, int64_t>::value));
CHECK(bool(etl::is_same<etl::larger_type_t<int64_t>, int64_t>::value));
CHECK(bool(etl::is_same<etl::larger_type_t<uint8_t>, uint16_t>::value));
CHECK(bool(etl::is_same<etl::larger_type_t<uint16_t>, uint32_t>::value));
CHECK(bool(etl::is_same<etl::larger_type_t<uint32_t>, uint64_t>::value));
CHECK(bool(etl::is_same<etl::larger_type_t<uint64_t>, uint64_t>::value));
}
};
}

View File

@ -55,6 +55,25 @@ namespace
CHECK(type);
}
//*************************************************************************
TEST(test_pod_vt)
{
size_t size;
bool type;
size = etl::smallest_type_v<char, short, int>;
type = etl::is_same<char, etl::smallest_type_t<char, short, int>>::value;
CHECK_EQUAL(sizeof(char), size);
CHECK(type);
size = etl::smallest_type<int, char, short>::size;
type = etl::is_same<char, etl::smallest_type<char, short, int>::type>::value;
CHECK_EQUAL(sizeof(char), size);
CHECK(type);
}
//*************************************************************************
TEST(test_non_pod)
{
@ -78,6 +97,29 @@ namespace
CHECK(type);
}
//*************************************************************************
TEST(test_non_pod_vt)
{
size_t size;
bool type;
struct S1 { char a; char b; char c; };
struct S2 { char a; short b; char c; };
struct S3 { int a; short b; char c; };
size = etl::smallest_type_v<S1, S2, S3>;
type = etl::is_same<S1, etl::smallest_type_t<S1, S2, S3>>::value;
CHECK_EQUAL(sizeof(S1), size);
CHECK(type);
size = etl::smallest_type_v<S2, S3, S1>;
type = etl::is_same<S1, etl::smallest_type_t<S2, S3, S1>>::value;
CHECK_EQUAL(sizeof(S1), size);
CHECK(type);
}
//*************************************************************************
TEST(test_smallest_uint_for_bits)
{
@ -120,6 +162,48 @@ namespace
CHECK(type);
}
//*************************************************************************
TEST(test_smallest_uint_for_bits_t)
{
bool type;
type = etl::is_same<uint_least8_t, etl::smallest_uint_for_bits_t<7>>::value;
CHECK(type);
type = etl::is_same<uint_least8_t, etl::smallest_uint_for_bits_t<8>>::value;
CHECK(type);
type = etl::is_same<uint_least16_t, etl::smallest_uint_for_bits_t<9>>::value;
CHECK(type);
type = etl::is_same<uint_least16_t, etl::smallest_uint_for_bits_t<15>>::value;
CHECK(type);
type = etl::is_same<uint_least16_t, etl::smallest_uint_for_bits_t<16>>::value;
CHECK(type);
type = etl::is_same<uint_least32_t, etl::smallest_uint_for_bits_t<17>>::value;
CHECK(type);
type = etl::is_same<uint_least32_t, etl::smallest_uint_for_bits_t<31>>::value;
CHECK(type);
type = etl::is_same<uint_least32_t, etl::smallest_uint_for_bits_t<32>>::value;
CHECK(type);
type = etl::is_same<uint_least64_t, etl::smallest_uint_for_bits_t<33>>::value;
CHECK(type);
type = etl::is_same<uint_least64_t, etl::smallest_uint_for_bits_t<63>>::value;
CHECK(type);
type = etl::is_same<uint_least64_t, etl::smallest_uint_for_bits_t<64>>::value;
CHECK(type);
type = etl::is_same<uint_least64_t, etl::smallest_uint_for_bits_t<65>>::value;
CHECK(type);
}
//*************************************************************************
TEST(test_smallest_int_for_bits)
{
@ -162,6 +246,48 @@ namespace
CHECK(type);
}
//*************************************************************************
TEST(test_smallest_int_for_bits_t)
{
bool type;
type = etl::is_same<int_least8_t, etl::smallest_int_for_bits_t<7>>::value;
CHECK(type);
type = etl::is_same<int_least8_t, etl::smallest_int_for_bits_t<8>>::value;
CHECK(type);
type = etl::is_same<int_least16_t, etl::smallest_int_for_bits_t<9>>::value;
CHECK(type);
type = etl::is_same<int_least16_t, etl::smallest_int_for_bits_t<15>>::value;
CHECK(type);
type = etl::is_same<int_least16_t, etl::smallest_int_for_bits_t<16>>::value;
CHECK(type);
type = etl::is_same<int_least32_t, etl::smallest_int_for_bits_t<17>>::value;
CHECK(type);
type = etl::is_same<int_least32_t, etl::smallest_int_for_bits_t<31>>::value;
CHECK(type);
type = etl::is_same<int_least32_t, etl::smallest_int_for_bits_t<32>>::value;
CHECK(type);
type = etl::is_same<int_least64_t, etl::smallest_int_for_bits_t<33>>::value;
CHECK(type);
type = etl::is_same<int_least64_t, etl::smallest_int_for_bits_t<63>>::value;
CHECK(type);
type = etl::is_same<int_least64_t, etl::smallest_int_for_bits_t<64>>::value;
CHECK(type);
type = etl::is_same<int_least64_t, etl::smallest_int_for_bits_t<65>>::value;
CHECK(type);
}
//*************************************************************************
TEST(test_smallest_uint_for_value)
{
@ -192,6 +318,36 @@ namespace
CHECK(type);
}
//*************************************************************************
TEST(test_smallest_uint_for_value_t)
{
bool type;
type = etl::is_same<uint_least8_t, etl::smallest_uint_for_value_t<0>>::value;
CHECK(type);
type = etl::is_same<uint_least8_t, etl::smallest_uint_for_value_t<UINT8_MAX>>::value;
CHECK(type);
type = etl::is_same<uint_least16_t, etl::smallest_uint_for_value_t<UINT8_MAX + 1>>::value;
CHECK(type);
type = etl::is_same<uint_least16_t, etl::smallest_uint_for_value_t<UINT16_MAX>>::value;
CHECK(type);
type = etl::is_same<uint_least32_t, etl::smallest_uint_for_value_t<UINT16_MAX + 1>>::value;
CHECK(type);
type = etl::is_same<uint_least32_t, etl::smallest_uint_for_value_t<UINT32_MAX>>::value;
CHECK(type);
type = etl::is_same<uint_least64_t, etl::smallest_uint_for_value_t<uint64_t(UINT32_MAX) + 1>>::value;
CHECK(type);
type = etl::is_same<uint_least64_t, etl::smallest_uint_for_value_t<UINT64_MAX>>::value;
CHECK(type);
}
//*************************************************************************
TEST(test_smallest_int_for_value)
{
@ -242,5 +398,56 @@ namespace
type = etl::is_same<int_least64_t, etl::smallest_int_for_value<INT64_MAX>::type>::value;
CHECK(type);
}
//*************************************************************************
TEST(test_smallest_int_for_value_t)
{
bool type;
type = etl::is_same<int_least8_t, etl::smallest_int_for_value_t<0>>::value;
CHECK(type);
type = etl::is_same<int_least8_t, etl::smallest_int_for_value_t<INT8_MIN>>::value;
CHECK(type);
type = etl::is_same<int_least8_t, etl::smallest_int_for_value_t<INT8_MAX>>::value;
CHECK(type);
type = etl::is_same<int_least16_t, etl::smallest_int_for_value_t<INT8_MIN - 1>>::value;
CHECK(type);
type = etl::is_same<int_least16_t, etl::smallest_int_for_value_t<INT8_MAX + 1>>::value;
CHECK(type);
type = etl::is_same<int_least16_t, etl::smallest_int_for_value_t<INT16_MIN>>::value;
CHECK(type);
type = etl::is_same<int_least16_t, etl::smallest_int_for_value_t<INT16_MAX>>::value;
CHECK(type);
type = etl::is_same<int_least32_t, etl::smallest_int_for_value_t<INT16_MIN - 1>>::value;
CHECK(type);
type = etl::is_same<int_least32_t, etl::smallest_int_for_value_t<INT16_MAX + 1>>::value;
CHECK(type);
type = etl::is_same<int_least32_t, etl::smallest_int_for_value_t<INT32_MIN>>::value;
CHECK(type);
type = etl::is_same<int_least32_t, etl::smallest_int_for_value_t<INT32_MAX>>::value;
CHECK(type);
type = etl::is_same<int_least64_t, etl::smallest_int_for_value_t<intmax_t(INT32_MIN) - 1>>::value;
CHECK(type);
type = etl::is_same<int_least64_t, etl::smallest_int_for_value_t<intmax_t(INT32_MAX) + 1>>::value;
CHECK(type);
type = etl::is_same<int_least64_t, etl::smallest_int_for_value_t<INT64_MIN>>::value;
CHECK(type);
type = etl::is_same<int_least64_t, etl::smallest_int_for_value_t<INT64_MAX>>::value;
CHECK(type);
}
};
}

View File

@ -135,6 +135,27 @@ namespace
CHECK((etl::is_same<Type16, typename Type_Id_Lookup16::type_from_id<Type16::ID>::type>::value));
}
//*************************************************************************
TEST(test_type_from_id_t_16)
{
CHECK((etl::is_same<Type1, typename Type_Id_Lookup16::type_from_id_t<Type1::ID>>::value));
CHECK((etl::is_same<Type2, typename Type_Id_Lookup16::type_from_id_t<Type2::ID>>::value));
CHECK((etl::is_same<Type3, typename Type_Id_Lookup16::type_from_id_t<Type3::ID>>::value));
CHECK((etl::is_same<Type4, typename Type_Id_Lookup16::type_from_id_t<Type4::ID>>::value));
CHECK((etl::is_same<Type5, typename Type_Id_Lookup16::type_from_id_t<Type5::ID>>::value));
CHECK((etl::is_same<Type6, typename Type_Id_Lookup16::type_from_id_t<Type6::ID>>::value));
CHECK((etl::is_same<Type7, typename Type_Id_Lookup16::type_from_id_t<Type7::ID>>::value));
CHECK((etl::is_same<Type8, typename Type_Id_Lookup16::type_from_id_t<Type8::ID>>::value));
CHECK((etl::is_same<Type9, typename Type_Id_Lookup16::type_from_id_t<Type9::ID>>::value));
CHECK((etl::is_same<Type10, typename Type_Id_Lookup16::type_from_id_t<Type10::ID>>::value));
CHECK((etl::is_same<Type11, typename Type_Id_Lookup16::type_from_id_t<Type11::ID>>::value));
CHECK((etl::is_same<Type12, typename Type_Id_Lookup16::type_from_id_t<Type12::ID>>::value));
CHECK((etl::is_same<Type13, typename Type_Id_Lookup16::type_from_id_t<Type13::ID>>::value));
CHECK((etl::is_same<Type14, typename Type_Id_Lookup16::type_from_id_t<Type14::ID>>::value));
CHECK((etl::is_same<Type15, typename Type_Id_Lookup16::type_from_id_t<Type15::ID>>::value));
CHECK((etl::is_same<Type16, typename Type_Id_Lookup16::type_from_id_t<Type16::ID>>::value));
}
//*************************************************************************
TEST(test_type_from_id_8)
{
@ -148,12 +169,31 @@ namespace
CHECK((etl::is_same<Type16, typename Type_Id_Lookup8::type_from_id<Type16::ID>::type>::value));
}
//*************************************************************************
TEST(test_type_from_id_t_8)
{
CHECK((etl::is_same<Type1, typename Type_Id_Lookup8::type_from_id_t<Type1::ID>>::value));
CHECK((etl::is_same<Type2, typename Type_Id_Lookup8::type_from_id_t<Type2::ID>>::value));
CHECK((etl::is_same<Type3, typename Type_Id_Lookup8::type_from_id_t<Type3::ID>>::value));
CHECK((etl::is_same<Type4, typename Type_Id_Lookup8::type_from_id_t<Type4::ID>>::value));
CHECK((etl::is_same<Type13, typename Type_Id_Lookup8::type_from_id_t<Type13::ID>>::value));
CHECK((etl::is_same<Type14, typename Type_Id_Lookup8::type_from_id_t<Type14::ID>>::value));
CHECK((etl::is_same<Type15, typename Type_Id_Lookup8::type_from_id_t<Type15::ID>>::value));
CHECK((etl::is_same<Type16, typename Type_Id_Lookup8::type_from_id_t<Type16::ID>>::value));
}
//*************************************************************************
TEST(test_type_from_id_1)
{
CHECK((etl::is_same<Type16, typename Type_Id_Lookup1::type_from_id<Type16::ID>::type>::value));
}
//*************************************************************************
TEST(test_type_from_id_t_1)
{
CHECK((etl::is_same<Type16, typename Type_Id_Lookup1::type_from_id_t<Type16::ID>>::value));
}
//*************************************************************************
TEST(test_id_from_type_16)
{
@ -208,6 +248,27 @@ namespace
CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type16()));
}
//*************************************************************************
TEST(test_id_from_type_v_16)
{
CHECK_EQUAL((unsigned int)Type1::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type1>);
CHECK_EQUAL((unsigned int)Type2::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type2>);
CHECK_EQUAL((unsigned int)Type3::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type3>);
CHECK_EQUAL((unsigned int)Type4::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type4>);
CHECK_EQUAL((unsigned int)Type5::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type5>);
CHECK_EQUAL((unsigned int)Type6::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type6>);
CHECK_EQUAL((unsigned int)Type7::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type7>);
CHECK_EQUAL((unsigned int)Type8::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type8>);
CHECK_EQUAL((unsigned int)Type9::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type9>);
CHECK_EQUAL((unsigned int)Type10::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type10>);
CHECK_EQUAL((unsigned int)Type11::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type11>);
CHECK_EQUAL((unsigned int)Type12::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type12>);
CHECK_EQUAL((unsigned int)Type13::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type13>);
CHECK_EQUAL((unsigned int)Type14::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type14>);
CHECK_EQUAL((unsigned int)Type15::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type15>);
CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v<Type16>);
}
//*************************************************************************
TEST(test_id_from_type_8)
{
@ -236,7 +297,19 @@ namespace
CHECK_EQUAL((unsigned int)Type15::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type(Type15()));
CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type<Type16>());
CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type(Type16()));
}
//*************************************************************************
TEST(test_id_from_type_v_8)
{
CHECK_EQUAL((unsigned int)Type1::ID, (unsigned int)Type_Id_Lookup8::id_from_type_v<Type1>);
CHECK_EQUAL((unsigned int)Type2::ID, (unsigned int)Type_Id_Lookup8::id_from_type_v<Type2>);
CHECK_EQUAL((unsigned int)Type3::ID, (unsigned int)Type_Id_Lookup8::id_from_type_v<Type3>);
CHECK_EQUAL((unsigned int)Type4::ID, (unsigned int)Type_Id_Lookup8::id_from_type_v<Type4>);
CHECK_EQUAL((unsigned int)Type13::ID, (unsigned int)Type_Id_Lookup8::id_from_type_v<Type13>);
CHECK_EQUAL((unsigned int)Type14::ID, (unsigned int)Type_Id_Lookup8::id_from_type_v<Type14>);
CHECK_EQUAL((unsigned int)Type15::ID, (unsigned int)Type_Id_Lookup8::id_from_type_v<Type15>);
CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup8::id_from_type_v<Type16>);
}
//*************************************************************************
@ -248,6 +321,12 @@ namespace
CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup1::get_id_from_type(Type16()));
}
//*************************************************************************
TEST(test_id_from_type_v_1)
{
CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup1::id_from_type_v<Type16>);
}
//*************************************************************************
TEST(test_type_from_type_16)
{
@ -269,6 +348,27 @@ namespace
CHECK((etl::is_same<Type15, typename Type_Type_Lookup16::type_from_type<Type16>::type>::value));
}
//*************************************************************************
TEST(test_type_from_type_t_16)
{
CHECK((etl::is_same<Type2, typename Type_Type_Lookup16::type_from_type_t<Type1>>::value));
CHECK((etl::is_same<Type1, typename Type_Type_Lookup16::type_from_type_t<Type2>>::value));
CHECK((etl::is_same<Type4, typename Type_Type_Lookup16::type_from_type_t<Type3>>::value));
CHECK((etl::is_same<Type3, typename Type_Type_Lookup16::type_from_type_t<Type4>>::value));
CHECK((etl::is_same<Type6, typename Type_Type_Lookup16::type_from_type_t<Type5>>::value));
CHECK((etl::is_same<Type5, typename Type_Type_Lookup16::type_from_type_t<Type6>>::value));
CHECK((etl::is_same<Type8, typename Type_Type_Lookup16::type_from_type_t<Type7>>::value));
CHECK((etl::is_same<Type7, typename Type_Type_Lookup16::type_from_type_t<Type8>>::value));
CHECK((etl::is_same<Type10, typename Type_Type_Lookup16::type_from_type_t<Type9>>::value));
CHECK((etl::is_same<Type9, typename Type_Type_Lookup16::type_from_type_t<Type10>>::value));
CHECK((etl::is_same<Type12, typename Type_Type_Lookup16::type_from_type_t<Type11>>::value));
CHECK((etl::is_same<Type11, typename Type_Type_Lookup16::type_from_type_t<Type12>>::value));
CHECK((etl::is_same<Type14, typename Type_Type_Lookup16::type_from_type_t<Type13>>::value));
CHECK((etl::is_same<Type13, typename Type_Type_Lookup16::type_from_type_t<Type14>>::value));
CHECK((etl::is_same<Type16, typename Type_Type_Lookup16::type_from_type_t<Type15>>::value));
CHECK((etl::is_same<Type15, typename Type_Type_Lookup16::type_from_type_t<Type16>>::value));
}
//*************************************************************************
TEST(test_type_from_type_8)
{
@ -282,10 +382,29 @@ namespace
CHECK((etl::is_same<Type7, typename Type_Type_Lookup8::type_from_type<Type8>::type>::value));
}
//*************************************************************************
TEST(test_type_from_type_t_8)
{
CHECK((etl::is_same<Type2, typename Type_Type_Lookup8::type_from_type_t<Type1>>::value));
CHECK((etl::is_same<Type1, typename Type_Type_Lookup8::type_from_type_t<Type2>>::value));
CHECK((etl::is_same<Type4, typename Type_Type_Lookup8::type_from_type_t<Type3>>::value));
CHECK((etl::is_same<Type3, typename Type_Type_Lookup8::type_from_type_t<Type4>>::value));
CHECK((etl::is_same<Type6, typename Type_Type_Lookup8::type_from_type_t<Type5>>::value));
CHECK((etl::is_same<Type5, typename Type_Type_Lookup8::type_from_type_t<Type6>>::value));
CHECK((etl::is_same<Type8, typename Type_Type_Lookup8::type_from_type_t<Type7>>::value));
CHECK((etl::is_same<Type7, typename Type_Type_Lookup8::type_from_type_t<Type8>>::value));
}
//*************************************************************************
TEST(test_type_from_type_1)
{
CHECK((etl::is_same<Type2, typename Type_Type_Lookup1::type_from_type<Type1>::type>::value));
}
//*************************************************************************
TEST(test_type_from_type_t_1)
{
CHECK((etl::is_same<Type2, typename Type_Type_Lookup1::type_from_type_t<Type1>>::value));
}
};
}

View File

@ -49,14 +49,21 @@ namespace
SUITE(test_type_lookup)
{
//*************************************************************************
TEST(test_type_select1)
TEST(test_type_select_1)
{
CHECK((etl::is_same<etl::null_type<0>, typename Types1::select<0>::type>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types1::select<0>::type>::value));
}
//*************************************************************************
TEST(test_type_select8)
TEST(test_type_select_t_1)
{
CHECK((etl::is_same<etl::null_type<0>, typename Types1::select_t<0>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types1::select_t<0>>::value));
}
//*************************************************************************
TEST(test_type_select_8)
{
CHECK((etl::is_same<etl::null_type<0>, typename Types8::select<0>::type>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types8::select<0>::type>::value));
@ -77,7 +84,28 @@ namespace
}
//*************************************************************************
TEST(test_type_select16)
TEST(test_type_select_t_8)
{
CHECK((etl::is_same<etl::null_type<0>, typename Types8::select_t<0>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types8::select_t<0>>::value));
CHECK((etl::is_same<etl::null_type<1>, typename Types8::select_t<1>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types8::select_t<1>>::value));
CHECK((etl::is_same<etl::null_type<2>, typename Types8::select_t<2>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types8::select_t<2>>::value));
CHECK((etl::is_same<etl::null_type<3>, typename Types8::select_t<3>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types8::select_t<3>>::value));
CHECK((etl::is_same<etl::null_type<4>, typename Types8::select_t<4>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types8::select_t<4>>::value));
CHECK((etl::is_same<etl::null_type<5>, typename Types8::select_t<5>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types8::select_t<5>>::value));
CHECK((etl::is_same<etl::null_type<6>, typename Types8::select_t<6>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types8::select_t<6>>::value));
CHECK((etl::is_same<etl::null_type<7>, typename Types8::select_t<7>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types8::select_t<7>>::value));
}
//*************************************************************************
TEST(test_type_select_16)
{
CHECK((etl::is_same<etl::null_type<0>, typename Types16::select<0>::type>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select<0>::type>::value));
@ -112,5 +140,42 @@ namespace
CHECK((etl::is_same<etl::null_type<15>, typename Types16::select<15>::type>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select<15>::type>::value));
}
//*************************************************************************
TEST(test_type_select_t_16)
{
CHECK((etl::is_same<etl::null_type<0>, typename Types16::select_t<0>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<0>>::value));
CHECK((etl::is_same<etl::null_type<1>, typename Types16::select_t<1>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<1>>::value));
CHECK((etl::is_same<etl::null_type<2>, typename Types16::select_t<2>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<2>>::value));
CHECK((etl::is_same<etl::null_type<3>, typename Types16::select_t<3>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<3>>::value));
CHECK((etl::is_same<etl::null_type<4>, typename Types16::select_t<4>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<4>>::value));
CHECK((etl::is_same<etl::null_type<5>, typename Types16::select_t<5>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<5>>::value));
CHECK((etl::is_same<etl::null_type<6>, typename Types16::select_t<6>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<6>>::value));
CHECK((etl::is_same<etl::null_type<7>, typename Types16::select_t<7>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<7>>::value));
CHECK((etl::is_same<etl::null_type<8>, typename Types16::select_t<8>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<8>>::value));
CHECK((etl::is_same<etl::null_type<9>, typename Types16::select_t<9>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<9>>::value));
CHECK((etl::is_same<etl::null_type<10>, typename Types16::select_t<10>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<10>>::value));
CHECK((etl::is_same<etl::null_type<11>, typename Types16::select_t<11>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<11>>::value));
CHECK((etl::is_same<etl::null_type<12>, typename Types16::select_t<12>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<12>>::value));
CHECK((etl::is_same<etl::null_type<13>, typename Types16::select_t<13>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<13>>::value));
CHECK((etl::is_same<etl::null_type<14>, typename Types16::select_t<14>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<14>>::value));
CHECK((etl::is_same<etl::null_type<15>, typename Types16::select_t<15>>::value));
CHECK(!(etl::is_same<etl::null_type<99>, typename Types16::select_t<15>>::value));
}
};
}