mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-30 14:28:44 +08:00
Improved implementation of etl::is_base_of_all
This commit is contained in:
parent
fc4c74721c
commit
24b241e10a
@ -1405,19 +1405,19 @@ typedef integral_constant<bool, true> true_type;
|
||||
//***************************************************************************
|
||||
/// Template to determine if a type is a base of all types in a specified list.
|
||||
///\ingroup types
|
||||
template <typename T, typename T1, typename... TRest>
|
||||
struct is_base_of_all
|
||||
template <typename TBase, typename... TDerived>
|
||||
struct is_base_of_all;
|
||||
|
||||
template <typename Base>
|
||||
struct is_base_of_all<Base> : etl::true_type
|
||||
{
|
||||
static const bool value = etl::is_base_of<T, T1>::value &&
|
||||
etl::is_base_of_all<T, TRest...>::value;
|
||||
};
|
||||
|
||||
template <typename T, typename T1>
|
||||
struct is_base_of_all<T, T1>
|
||||
template <typename TBase, typename TFirst, typename... TRest>
|
||||
struct is_base_of_all<TBase, TFirst, TRest...> : etl::integral_constant<bool, etl::is_base_of<TBase, TFirst>::value &&
|
||||
etl::is_base_of_all<TBase, TRest...>::value>
|
||||
{
|
||||
static const bool value = etl::is_base_of<T, T1>::value;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
template <typename T, typename... TRest>
|
||||
|
||||
@ -1398,23 +1398,24 @@ typedef integral_constant<bool, true> true_type;
|
||||
//***************************************************************************
|
||||
/// Template to determine if a type is a base of all types in a specified list.
|
||||
///\ingroup types
|
||||
template <typename T, typename T1, typename... TRest>
|
||||
struct is_base_of_all
|
||||
template <typename TBase, typename... TDerived>
|
||||
struct is_base_of_all;
|
||||
|
||||
template <typename Base>
|
||||
struct is_base_of_all<Base> : etl::true_type
|
||||
{
|
||||
static const bool value = etl::is_base_of<T, T1>::value &&
|
||||
etl::is_base_of_all<T, TRest...>::value;
|
||||
};
|
||||
|
||||
template <typename T, typename T1>
|
||||
struct is_base_of_all<T, T1>
|
||||
template <typename TBase, typename TFirst, typename... TRest>
|
||||
struct is_base_of_all<TBase, TFirst, TRest...> : etl::integral_constant<bool, etl::is_base_of<TBase, TFirst>::value &&
|
||||
etl::is_base_of_all<TBase, TRest...>::value>
|
||||
{
|
||||
static const bool value = etl::is_base_of<T, T1>::value;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
template <typename T, typename... TRest>
|
||||
inline constexpr bool is_base_of_all_v = etl::is_base_of_all<T, TRest...>::value;
|
||||
template <typename TBase, typename... TRest>
|
||||
inline constexpr bool is_base_of_all_v = etl::is_base_of_all<TBase, TRest...>::value;
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
|
||||
@ -1320,9 +1320,11 @@ namespace
|
||||
struct D4 {};
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
CHECK_TRUE(bool(etl::is_base_of_all_v<Base, D1>));
|
||||
CHECK_TRUE(bool(etl::is_base_of_all_v<Base, D1, D2, D3>));
|
||||
CHECK_FALSE(bool(etl::is_base_of_all_v<Base, D1, D2, D3, D4>));
|
||||
#else
|
||||
CHECK_TRUE(bool(etl::is_base_of_all<Base, D1>::value));
|
||||
CHECK_TRUE(bool(etl::is_base_of_all<Base, D1, D2, D3>::value));
|
||||
CHECK_FALSE(bool(etl::is_base_of_all<Base, D1, D2, D3, D4>::value));
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user