mirror of
https://github.com/ETLCPP/etl.git
synced 2026-10-28 18:07:10 +08:00
Removed etl::type_tag and replaced its use with etl::in_place_type_t
This commit is contained in:
parent
8826b56493
commit
4737fd0f03
@ -55,7 +55,7 @@ namespace etl
|
||||
template <typename TMessage, typename TPool, typename... TArgs>
|
||||
static shared_message create(TPool& owner, TArgs&&... args)
|
||||
{
|
||||
return shared_message(owner, etl::type_tag<TMessage>(), etl::forward<TArgs>(args)...);
|
||||
return shared_message(owner, etl::in_place_type_t<TMessage>(), etl::forward<TArgs>(args)...);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -79,7 +79,7 @@ namespace etl
|
||||
/// Constructor
|
||||
//*************************************************************************
|
||||
template <typename TPool, typename TMessage, typename... TArgs>
|
||||
shared_message(TPool& owner, etl::type_tag<TMessage>, TArgs&&... args)
|
||||
shared_message(TPool& owner, etl::in_place_type_t<TMessage>, TArgs&&... args)
|
||||
{
|
||||
ETL_STATIC_ASSERT((etl::is_base_of<etl::ireference_counted_message_pool, TPool>::value), "TPool not derived from etl::ireference_counted_message_pool");
|
||||
ETL_STATIC_ASSERT((etl::is_base_of<etl::imessage, TMessage>::value), "TMessage not derived from etl::imessage");
|
||||
|
||||
@ -672,56 +672,6 @@ namespace etl
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
/// A tag that can be used as a concrete object to identify a type.
|
||||
//*****************************************************************************
|
||||
template <typename T>
|
||||
struct type_tag
|
||||
{
|
||||
typedef T type;
|
||||
typedef typename etl::remove_cvref<T>::type underlying_type;
|
||||
};
|
||||
|
||||
//***********************************
|
||||
/// Equality operator for type_tag
|
||||
//***********************************
|
||||
template <typename T1, typename T2>
|
||||
ETL_CONSTEXPR bool operator ==(etl::type_tag<T1>, etl::type_tag<T2>)
|
||||
{
|
||||
return etl::is_same<etl::type_tag<T1>, etl::type_tag<T2> >::value;
|
||||
}
|
||||
|
||||
//***********************************
|
||||
/// Inequality operator for type_tag
|
||||
//***********************************
|
||||
template <typename T1, typename T2>
|
||||
ETL_CONSTEXPR bool operator !=(etl::type_tag<T1>, etl::type_tag<T2>)
|
||||
{
|
||||
return !etl::is_same<etl::type_tag<T1>, etl::type_tag<T2> >::value;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//***********************************
|
||||
/// type_tag type
|
||||
//***********************************
|
||||
template <typename T>
|
||||
using type_tag_t = typename etl::type_tag<T>::type;
|
||||
|
||||
//***********************************
|
||||
/// type_tag underlying type
|
||||
//***********************************
|
||||
template <typename T>
|
||||
using type_tag_underlying_t = typename etl::type_tag<T>::underlying_type;
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
//***********************************
|
||||
/// constexpr type_tag value
|
||||
//***********************************
|
||||
template <typename T>
|
||||
inline constexpr etl::type_tag<T> type_tag_v = etl::type_tag<T>{};
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -666,71 +666,5 @@ namespace
|
||||
CHECK_EQUAL(forward_like_call_type::ConstRValue, template_function_fl<TFL&&>(etl::move(u4)));
|
||||
CHECK_EQUAL(forward_like_call_type::ConstRValue, template_function_fl<const TFL&&>(etl::move(u4)));
|
||||
}
|
||||
|
||||
//*********************************
|
||||
TEST(test_type_tag)
|
||||
{
|
||||
using TypeTag1 = etl::type_tag<int>;
|
||||
using TypeTag2 = etl::type_tag<const int>;
|
||||
using TypeTag3 = etl::type_tag<double>;
|
||||
|
||||
TypeTag1 typeTag1;
|
||||
TypeTag2 typeTag2;
|
||||
TypeTag3 typeTag3;
|
||||
|
||||
CHECK_TRUE(typeTag1 == typeTag1);
|
||||
CHECK_TRUE(typeTag2 == typeTag2);
|
||||
CHECK_TRUE(typeTag3 == typeTag3);
|
||||
|
||||
CHECK_FALSE(typeTag1 == typeTag2);
|
||||
CHECK_FALSE(typeTag2 == typeTag3);
|
||||
CHECK_FALSE(typeTag3 == typeTag1);
|
||||
|
||||
CHECK_FALSE(typeTag1 != typeTag1);
|
||||
CHECK_FALSE(typeTag2 != typeTag2);
|
||||
CHECK_FALSE(typeTag3 != typeTag3);
|
||||
|
||||
CHECK_TRUE(typeTag1 != typeTag2);
|
||||
CHECK_TRUE(typeTag2 != typeTag3);
|
||||
CHECK_TRUE(typeTag3 != typeTag1);
|
||||
}
|
||||
|
||||
//*********************************
|
||||
TEST(test_type_tag_t)
|
||||
{
|
||||
using TypeTagType1 = etl::type_tag_t<int>;
|
||||
using TypeTagType2 = etl::type_tag_t<const int>;
|
||||
using TypeTagType3 = etl::type_tag_t<volatile int>;
|
||||
|
||||
CHECK_FALSE((std::is_same<TypeTagType1, TypeTagType2>::value));
|
||||
CHECK_FALSE((std::is_same<TypeTagType2, TypeTagType3>::value));
|
||||
CHECK_FALSE((std::is_same<TypeTagType3, TypeTagType1>::value));
|
||||
}
|
||||
|
||||
//*********************************
|
||||
TEST(test_type_tag_underlying_t)
|
||||
{
|
||||
using TypeTagType1 = etl::type_tag_underlying_t<int>;
|
||||
using TypeTagType2 = etl::type_tag_underlying_t<const int>;
|
||||
using TypeTagType3 = etl::type_tag_underlying_t<volatile int>;
|
||||
|
||||
CHECK_TRUE((std::is_same<TypeTagType1, TypeTagType2>::value));
|
||||
CHECK_TRUE((std::is_same<TypeTagType2, TypeTagType3>::value));
|
||||
CHECK_TRUE((std::is_same<TypeTagType3, TypeTagType1>::value));
|
||||
}
|
||||
|
||||
//*********************************
|
||||
#if ETL_USING_CPP17
|
||||
TEST(test_type_tag_v)
|
||||
{
|
||||
constexpr auto typeTag1 = etl::type_tag_v<int>;
|
||||
constexpr auto typeTag2 = etl::type_tag_v<const int>;
|
||||
constexpr auto typeTag3 = etl::type_tag_v<volatile int>;
|
||||
|
||||
CHECK_TRUE(typeTag1 == typeTag1);
|
||||
CHECK_TRUE(typeTag2 == typeTag2);
|
||||
CHECK_TRUE(typeTag3 == typeTag3);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user