refactor(typetraits): make TConstant more in line with std style
This commit is contained in:
parent
c973a8674b
commit
c37f2c3153
@ -47,9 +47,9 @@ void TestTypeTraits()
|
||||
{
|
||||
// HelperClasses.h
|
||||
|
||||
always_check(TypeTraits::TIntegralConstant<1>::Value == 1);
|
||||
always_check(static_cast<int32>(TypeTraits::TIntegralConstant<2>::Value) == 2);
|
||||
always_check(TypeTraits::TIntegralConstant<3>() == 3);
|
||||
always_check((TypeTraits::TConstant<int32, 1>::Value == 1));
|
||||
always_check(static_cast<int32>(TypeTraits::TConstant<int32, 2>::Value) == 2);
|
||||
always_check((TypeTraits::TConstant<int32, 3>() == 3));
|
||||
|
||||
always_check(!TypeTraits::FFalse::Value);
|
||||
always_check(TypeTraits::FTrue::Value);
|
||||
|
@ -10,18 +10,16 @@ NAMESPACE_BEGIN(TypeTraits)
|
||||
template <typename InType, InType InValue>
|
||||
struct TConstant
|
||||
{
|
||||
using Type = InType;
|
||||
static constexpr Type Value = InValue;
|
||||
constexpr operator Type() const { return Value; }
|
||||
constexpr Type operator()() const { return Value; }
|
||||
using ValueType = InType;
|
||||
using Type = TConstant;
|
||||
static constexpr ValueType Value = InValue;
|
||||
constexpr operator ValueType() const { return Value; }
|
||||
constexpr ValueType operator()() const { return Value; }
|
||||
};
|
||||
|
||||
template <bool InValue>
|
||||
using TBoolConstant = TConstant<bool, InValue>;
|
||||
|
||||
template <int32 InValue>
|
||||
using TIntegralConstant = TConstant<int32, InValue>;
|
||||
|
||||
using FTrue = TBoolConstant<true>;
|
||||
using FFalse = TBoolConstant<false>;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user