diff --git a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp index 30c846a..5cd928b 100644 --- a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp @@ -413,14 +413,6 @@ void TestTypeTraits() always_check((TIsSame::Type>::Value)); always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); always_check((TIsSame::Type>::Value)); always_check((TIsSame::Type>::Value)); @@ -433,6 +425,16 @@ void TestTypeTraits() always_check((TIsSame::Type>::Value)); always_check((TIsSame::Type>::Value)); + // Common.h + + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + } NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Common.h b/Redcraft.Utility/Source/Public/TypeTraits/Common.h new file mode 100644 index 0000000..80778a6 --- /dev/null +++ b/Redcraft.Utility/Source/Public/TypeTraits/Common.h @@ -0,0 +1,29 @@ +#pragma once + +#include "CoreTypes.h" +#include "TypeTraits/HelperClasses.h" + +#include + +NAMESPACE_REDCRAFT_BEGIN +NAMESPACE_MODULE_BEGIN(Redcraft) +NAMESPACE_MODULE_BEGIN(Utility) + +NAMESPACE_PRIVATE_BEGIN + +struct FNoopStruct { }; + +template concept CCommonType = requires { typename NAMESPACE_STD::common_type_t; }; +template concept CCommonReference = requires { typename NAMESPACE_STD::common_reference_t; }; + +template struct TCommonType { using Type = NAMESPACE_STD::common_type_t; }; +template struct TCommonReference { using Type = NAMESPACE_STD::common_reference_t; }; + +NAMESPACE_PRIVATE_END + +template struct TCommonType : TConditional, NAMESPACE_PRIVATE::TCommonType, NAMESPACE_PRIVATE::FNoopStruct>::Type { }; +template struct TCommonReference : TConditional, NAMESPACE_PRIVATE::TCommonReference, NAMESPACE_PRIVATE::FNoopStruct>::Type { }; + +NAMESPACE_MODULE_END(Utility) +NAMESPACE_MODULE_END(Redcraft) +NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h b/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h index a51a471..32b64b8 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h @@ -50,8 +50,6 @@ template struct TAlignedUnion { using Type = template struct TDecay { using Type = NAMESPACE_STD::decay_t; }; template struct TEnableIf { using Type = NAMESPACE_STD::enable_if_t; }; template struct TConditional { using Type = NAMESPACE_STD::conditional_t; }; -template struct TCommonType { using Type = NAMESPACE_STD::common_type_t; }; -template struct TCommonReference { using Type = NAMESPACE_STD::common_reference_t; }; template struct TUnderlyingType { using Type = NAMESPACE_STD::underlying_type_t; }; template struct TInvokeResult { using Type = NAMESPACE_STD::invoke_result_t; }; // FIXME: The result for char(&())[2] is wrong on MSVC template struct TVoid { using Type = void; }; diff --git a/Redcraft.Utility/Source/Public/TypeTraits/TypeTraits.h b/Redcraft.Utility/Source/Public/TypeTraits/TypeTraits.h index c925295..7831cde 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/TypeTraits.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/TypeTraits.h @@ -7,3 +7,4 @@ #include "TypeTraits/TypeProperties.h" #include "TypeTraits/SupportedOperations.h" #include "TypeTraits/Miscellaneous.h" +#include "TypeTraits/Common.h"