Added is_enum

This commit is contained in:
John Wellbelove 2022-07-14 17:31:20 +01:00
parent 4d4a3c8ab9
commit 67c2efb85c
3 changed files with 43 additions and 8 deletions

View File

@ -704,7 +704,7 @@ namespace etl
#endif
//***************************************************************************
/// decval
/// declval
#if ETL_USING_CPP11
template <typename T>
typename etl::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
@ -742,7 +742,7 @@ namespace etl
inline constexpr bool is_enum_v = etl::is_enum<T>::value;
#endif
#endif // ETL_USING_CPP11
#endif
//***************************************************************************
/// is_convertible
@ -1256,10 +1256,26 @@ namespace etl
#endif
//***************************************************************************
/// decval
/// declval
#if ETL_USING_CPP11
template <typename T>
typename std::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
#endif
#if ETL_USING_CPP11
//***************************************************************************
/// is_enum
///\ingroup type_traits
template <typename T>
struct is_enum : std::is_enum<T>
{
};
#if ETL_USING_CPP17
template <typename T>
inline constexpr bool is_enum_v = etl::is_enum<T>::value;
#endif
#endif
//***************************************************************************

View File

@ -692,7 +692,7 @@ namespace etl
#endif
//***************************************************************************
/// decval
/// declval
#if ETL_USING_CPP11
template <typename T>
typename etl::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
@ -730,7 +730,7 @@ namespace etl
inline constexpr bool is_enum_v = etl::is_enum<T>::value;
#endif
#endif // ETL_USING_CPP11
#endif
//***************************************************************************
/// is_convertible
@ -1244,10 +1244,26 @@ namespace etl
#endif
//***************************************************************************
/// decval
/// declval
#if ETL_USING_CPP11
template <typename T>
typename std::add_rvalue_reference<T>::type declval() ETL_NOEXCEPT;
#endif
#if ETL_USING_CPP11
//***************************************************************************
/// is_enum
///\ingroup type_traits
template <typename T>
struct is_enum : std::is_enum<T>
{
};
#if ETL_USING_CPP17
template <typename T>
inline constexpr bool is_enum_v = etl::is_enum<T>::value;
#endif
#endif
//***************************************************************************

View File

@ -67,14 +67,16 @@ namespace
};
// Class which can be implicitly converted to/from any default-constructable type
struct ToAny {
struct ToAny
{
ToAny() = default;
template <typename T> ToAny(T){};
template <typename T> operator T() { return T(); }
};
// Can't be default constructed
struct NotDefaultConstructable {
struct NotDefaultConstructable
{
NotDefaultConstructable() = delete;
};
@ -985,6 +987,7 @@ namespace
//*************************************************************************
#define CHECK_EQUAL_FOR_TYPE(type) CHECK_EQUAL(std::is_enum_v<type>, etl::is_enum_v<type>)
TEST(test_is_enum) {
CHECK_EQUAL_FOR_TYPE(void);
CHECK_EQUAL_FOR_TYPE(void*);