feat(typetraits): add CDerivedFrom and the corresponding testing
This commit is contained in:
parent
c7e3ac32b4
commit
d825285a4a
@ -322,6 +322,10 @@ void TestTypeTraits()
|
|||||||
always_check(!(CConvertibleTo<FTestStructE*, FTestStructH*>));
|
always_check(!(CConvertibleTo<FTestStructE*, FTestStructH*>));
|
||||||
always_check((CConvertibleTo<FTestStructW, FTestStructV>));
|
always_check((CConvertibleTo<FTestStructW, FTestStructV>));
|
||||||
|
|
||||||
|
always_check(!(CDerivedFrom<FTestStructD, FTestStructH>));
|
||||||
|
always_check(!(CDerivedFrom<FTestStructE, FTestStructH>));
|
||||||
|
always_check((CDerivedFrom<FTestStructH, FTestStructE>));
|
||||||
|
|
||||||
always_check((CSameAs<int32, TRemoveConst<int32>>));
|
always_check((CSameAs<int32, TRemoveConst<int32>>));
|
||||||
always_check(!(CSameAs<int32, TRemoveConst<int32*>>));
|
always_check(!(CSameAs<int32, TRemoveConst<int32*>>));
|
||||||
always_check(!(CSameAs<int32, TRemoveConst<int32&>>));
|
always_check(!(CSameAs<int32, TRemoveConst<int32&>>));
|
||||||
|
@ -31,6 +31,7 @@ template <typename T, size_t I = 0> inline constexpr size_t TExtent = NAMESPACE
|
|||||||
template <typename T, typename U> concept CSameAs = NAMESPACE_STD::is_same_v<T, U>;
|
template <typename T, typename U> concept CSameAs = NAMESPACE_STD::is_same_v<T, U>;
|
||||||
template <typename T, typename U> concept CBaseOf = NAMESPACE_STD::is_base_of_v<T, U>;
|
template <typename T, typename U> concept CBaseOf = NAMESPACE_STD::is_base_of_v<T, U>;
|
||||||
template <typename T, typename U> concept CConvertibleTo = NAMESPACE_STD::is_convertible_v<T, U>;
|
template <typename T, typename U> concept CConvertibleTo = NAMESPACE_STD::is_convertible_v<T, U>;
|
||||||
|
template <typename T, typename U> concept CDerivedFrom = CBaseOf<U, T> && CConvertibleTo<const volatile T*, const volatile U*>;
|
||||||
|
|
||||||
template <typename T> using TRemoveConst = NAMESPACE_STD::remove_const_t<T>;
|
template <typename T> using TRemoveConst = NAMESPACE_STD::remove_const_t<T>;
|
||||||
template <typename T> using TRemoveVolatile = NAMESPACE_STD::remove_volatile_t<T>;
|
template <typename T> using TRemoveVolatile = NAMESPACE_STD::remove_volatile_t<T>;
|
||||||
|
Loading…
Reference in New Issue
Block a user