From c37f2c315371f58057a62977aba2c2b5ffd07521 Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Mon, 20 Dec 2021 22:41:11 +0800 Subject: [PATCH] refactor(typetraits): make TConstant more in line with std style --- .../Source/Private/Testing/TypeTraitsTesting.cpp | 6 +++--- .../Source/Public/TypeTraits/HelperClasses.h | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp index eb464c2..4eb5ef6 100644 --- a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp @@ -47,9 +47,9 @@ void TestTypeTraits() { // HelperClasses.h - always_check(TypeTraits::TIntegralConstant<1>::Value == 1); - always_check(static_cast(TypeTraits::TIntegralConstant<2>::Value) == 2); - always_check(TypeTraits::TIntegralConstant<3>() == 3); + always_check((TypeTraits::TConstant::Value == 1)); + always_check(static_cast(TypeTraits::TConstant::Value) == 2); + always_check((TypeTraits::TConstant() == 3)); always_check(!TypeTraits::FFalse::Value); always_check(TypeTraits::FTrue::Value); diff --git a/Redcraft.Utility/Source/Public/TypeTraits/HelperClasses.h b/Redcraft.Utility/Source/Public/TypeTraits/HelperClasses.h index e2bc9f4..5fc760b 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/HelperClasses.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/HelperClasses.h @@ -10,18 +10,16 @@ NAMESPACE_BEGIN(TypeTraits) template 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 using TBoolConstant = TConstant; -template -using TIntegralConstant = TConstant; - using FTrue = TBoolConstant; using FFalse = TBoolConstant;