Variadic versions of etl::type_id_lookup and etl::type_type_lookup for C++11 and above.

This commit is contained in:
John Wellbelove 2020-05-21 13:52:26 +01:00
parent f6089458c5
commit 79dcebaac3
2 changed files with 32 additions and 42 deletions

View File

@ -111,23 +111,11 @@ namespace etl
template <typename T, const T VALUE>
const T integral_constant<T, VALUE>::value;
#if ETL_CPP17_SUPPORTED
#if ETL_CPP11_SUPPORTED
template <bool B>
using bool_constant = integral_constant<bool, B>;
#endif
//***************************************************************************
/// bool_constant
template <bool B>
struct bool_constant :etl::integral_constant<bool, B>
{
};
#if ETL_CPP17_SUPPORTED
template <bool B>
inline constexpr bool bool_constant_v = bool_constant<B>::value;
#endif
//***************************************************************************
/// negation
template <typename T>
@ -813,6 +801,16 @@ namespace etl
using bool_constant = std::bool_constant<B>;
#endif
#if ETTL_CPP17_SUPPORTED
template <typename T>
struct negation : std::negation<T>
{
};
template <typename T>
inline constexpr bool negation_v = std::negation_v<T>;
#endif
//***************************************************************************
/// remove_reference
///\ingroup type_traits
@ -1563,11 +1561,8 @@ namespace etl
{
private:
template <typename T, typename... TTypes>
struct index_of_helper;
template <typename T, typename T1, typename... TRest>
struct index_of_helper<T, T1, TRest...>
template <typename T1, typename... TRest>
struct index_of_helper
{
enum
{
@ -1575,8 +1570,8 @@ namespace etl
};
};
template <typename T, typename T1>
struct index_of_helper<T, T1>
template <typename T1>
struct index_of_helper<T1>
{
enum
{
@ -1590,7 +1585,7 @@ namespace etl
enum
{
value = etl::is_one_of<T, TTypes...>::value ? private_type_traits::index_of_helper<T, TTypes...>::value - 1 : npos
value = etl::is_one_of<T, TTypes...>::value ? index_of_helper<TTypes...>::value - 1 : npos
};
};
}

View File

@ -99,23 +99,11 @@ namespace etl
template <typename T, const T VALUE>
const T integral_constant<T, VALUE>::value;
#if ETL_CPP17_SUPPORTED
#if ETL_CPP11_SUPPORTED
template <bool B>
using bool_constant = integral_constant<bool, B>;
#endif
//***************************************************************************
/// bool_constant
template <bool B>
struct bool_constant :etl::integral_constant<bool, B>
{
};
#if ETL_CPP17_SUPPORTED
template <bool B>
inline constexpr bool bool_constant_v = bool_constant<B>::value;
#endif
//***************************************************************************
/// negation
template <typename T>
@ -801,6 +789,16 @@ namespace etl
using bool_constant = std::bool_constant<B>;
#endif
#if ETTL_CPP17_SUPPORTED
template <typename T>
struct negation : std::negation<T>
{
};
template <typename T>
inline constexpr bool negation_v = std::negation_v<T>;
#endif
//***************************************************************************
/// remove_reference
///\ingroup type_traits
@ -1556,11 +1554,8 @@ namespace etl
{
private:
template <typename T, typename... TTypes>
struct index_of_helper;
template <typename T, typename T1, typename... TRest>
struct index_of_helper<T, T1, TRest...>
template <typename T1, typename... TRest>
struct index_of_helper
{
enum
{
@ -1568,8 +1563,8 @@ namespace etl
};
};
template <typename T, typename T1>
struct index_of_helper<T, T1>
template <typename T1>
struct index_of_helper<T1>
{
enum
{
@ -1583,7 +1578,7 @@ namespace etl
enum
{
value = etl::is_one_of<T, TTypes...>::value ? private_type_traits::index_of_helper<T, TTypes...>::value - 1 : npos
value = etl::is_one_of<T, TTypes...>::value ? index_of_helper<TTypes...>::value - 1 : npos
};
};
}