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
|
// HelperClasses.h
|
||||||
|
|
||||||
always_check(TypeTraits::TIntegralConstant<1>::Value == 1);
|
always_check((TypeTraits::TConstant<int32, 1>::Value == 1));
|
||||||
always_check(static_cast<int32>(TypeTraits::TIntegralConstant<2>::Value) == 2);
|
always_check(static_cast<int32>(TypeTraits::TConstant<int32, 2>::Value) == 2);
|
||||||
always_check(TypeTraits::TIntegralConstant<3>() == 3);
|
always_check((TypeTraits::TConstant<int32, 3>() == 3));
|
||||||
|
|
||||||
always_check(!TypeTraits::FFalse::Value);
|
always_check(!TypeTraits::FFalse::Value);
|
||||||
always_check(TypeTraits::FTrue::Value);
|
always_check(TypeTraits::FTrue::Value);
|
||||||
|
@ -10,18 +10,16 @@ NAMESPACE_BEGIN(TypeTraits)
|
|||||||
template <typename InType, InType InValue>
|
template <typename InType, InType InValue>
|
||||||
struct TConstant
|
struct TConstant
|
||||||
{
|
{
|
||||||
using Type = InType;
|
using ValueType = InType;
|
||||||
static constexpr Type Value = InValue;
|
using Type = TConstant;
|
||||||
constexpr operator Type() const { return Value; }
|
static constexpr ValueType Value = InValue;
|
||||||
constexpr Type operator()() const { return Value; }
|
constexpr operator ValueType() const { return Value; }
|
||||||
|
constexpr ValueType operator()() const { return Value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <bool InValue>
|
template <bool InValue>
|
||||||
using TBoolConstant = TConstant<bool, InValue>;
|
using TBoolConstant = TConstant<bool, InValue>;
|
||||||
|
|
||||||
template <int32 InValue>
|
|
||||||
using TIntegralConstant = TConstant<int32, InValue>;
|
|
||||||
|
|
||||||
using FTrue = TBoolConstant<true>;
|
using FTrue = TBoolConstant<true>;
|
||||||
using FFalse = TBoolConstant<false>;
|
using FFalse = TBoolConstant<false>;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user