feat(typetraits): add TypeTraits/CopyQualifiers.h and the corresponding testing
This commit is contained in:
parent
f7b611febc
commit
8188d29a58
@ -450,6 +450,84 @@ void TestTypeTraits()
|
|||||||
|
|
||||||
always_check((TIsSwappableWith<int32&, int32&>::Value));
|
always_check((TIsSwappableWith<int32&, int32&>::Value));
|
||||||
|
|
||||||
|
// CopyQualifiers.h
|
||||||
|
|
||||||
|
always_check((TIsSame< int32, TCopyConst< int32, int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyConst<const int32, int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyConst<const volatile int32, int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyConst< int32, const int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyConst<const int32, const int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyConst<const volatile int32, const int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyConst< int32, const volatile int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyConst<const int32, const volatile int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyConst<const volatile int32, const volatile int32>::Type>::Value));
|
||||||
|
|
||||||
|
always_check((TIsSame< int32, TCopyVolatile< int32, int32>::Type>::Value));
|
||||||
|
always_check((TIsSame< int32, TCopyVolatile<const int32, int32>::Type>::Value));
|
||||||
|
always_check((TIsSame< volatile int32, TCopyVolatile<const volatile int32, int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyVolatile< int32, const int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyVolatile<const int32, const int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyVolatile<const volatile int32, const int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyVolatile< int32, const volatile int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyVolatile<const int32, const volatile int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyVolatile<const volatile int32, const volatile int32>::Type>::Value));
|
||||||
|
|
||||||
|
always_check((TIsSame< int32, TCopyCV< int32, int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyCV<const int32, int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyCV<const volatile int32, int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyCV< int32, const int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyCV<const int32, const int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyCV<const volatile int32, const int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyCV< int32, const volatile int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyCV<const int32, const volatile int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyCV<const volatile int32, const volatile int32>::Type>::Value));
|
||||||
|
|
||||||
|
always_check((TIsSame<int32, TCopyReference<int32, int32 >::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&, TCopyReference<int32, int32& >::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&&, TCopyReference<int32, int32&&>::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&, TCopyReference<int32&, int32 >::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&, TCopyReference<int32&, int32& >::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&, TCopyReference<int32&, int32&&>::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&&, TCopyReference<int32&&, int32 >::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&, TCopyReference<int32&&, int32& >::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&&, TCopyReference<int32&&, int32&&>::Type>::Value));
|
||||||
|
|
||||||
|
always_check((TIsSame< int32, TCopyCVRef< int32, int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyCVRef<const int32, int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyCVRef< int32, const int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyCVRef<const int32, const int32>::Type>::Value));
|
||||||
|
always_check((TIsSame< volatile int32, TCopyCVRef< volatile int32, int32>::Type>::Value));
|
||||||
|
always_check((TIsSame< volatile int32, TCopyCVRef< int32, volatile int32>::Type>::Value));
|
||||||
|
always_check((TIsSame< volatile int32, TCopyCVRef< volatile int32, volatile int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyCVRef<const int32, int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyCVRef<const volatile int32, int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyCVRef< int32, const int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32, TCopyCVRef<const int32, const int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyCVRef<const volatile int32, const int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyCVRef< int32, const volatile int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyCVRef<const int32, const volatile int32>::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32, TCopyCVRef<const volatile int32, const volatile int32>::Type>::Value));
|
||||||
|
|
||||||
|
always_check((TIsSame<int32, TCopyCVRef<int32, int32 >::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&, TCopyCVRef<int32, int32& >::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&&, TCopyCVRef<int32, int32&&>::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&, TCopyCVRef<int32&, int32 >::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&, TCopyCVRef<int32&, int32& >::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&, TCopyCVRef<int32&, int32&&>::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&&, TCopyCVRef<int32&&, int32 >::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&, TCopyCVRef<int32&&, int32& >::Type>::Value));
|
||||||
|
always_check((TIsSame<int32&&, TCopyCVRef<int32&&, int32&&>::Type>::Value));
|
||||||
|
|
||||||
|
always_check((TIsSame<const int32, TCopyCVRef<const int32, int32 >::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32&, TCopyCVRef< int32, const int32& >::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32&&, TCopyCVRef<const volatile int32, const int32&&>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32&, TCopyCVRef<const int32&, int32 >::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32&, TCopyCVRef<const int32&, const int32& >::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32&, TCopyCVRef< volatile int32&, const int32&&>::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32&&, TCopyCVRef<const int32&&, int32 >::Type>::Value));
|
||||||
|
always_check((TIsSame<const int32&, TCopyCVRef<const int32&&, const int32& >::Type>::Value));
|
||||||
|
always_check((TIsSame<const volatile int32&&, TCopyCVRef<const volatile int32&&, const int32&&>::Type>::Value));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NAMESPACE_MODULE_END(Utility)
|
NAMESPACE_MODULE_END(Utility)
|
||||||
|
36
Redcraft.Utility/Source/Public/TypeTraits/CopyQualifiers.h
Normal file
36
Redcraft.Utility/Source/Public/TypeTraits/CopyQualifiers.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreTypes.h"
|
||||||
|
#include "TypeTraits/HelperClasses.h"
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
NAMESPACE_REDCRAFT_BEGIN
|
||||||
|
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||||
|
NAMESPACE_MODULE_BEGIN(Utility)
|
||||||
|
|
||||||
|
template <typename From, typename To> struct TCopyConst { using Type = To; };
|
||||||
|
template <typename From, typename To> struct TCopyConst<const From, To> { using Type = const To; };
|
||||||
|
|
||||||
|
template <typename From, typename To> struct TCopyVolatile { using Type = To; };
|
||||||
|
template <typename From, typename To> struct TCopyVolatile<volatile From, To> { using Type = volatile To; };
|
||||||
|
|
||||||
|
template <typename From, typename To> struct TCopyCV { using Type = typename TCopyConst<From, typename TCopyVolatile<From, To>::Type>::Type; };
|
||||||
|
|
||||||
|
template <typename From, typename To> struct TCopyReference { using Type = To; };
|
||||||
|
template <typename From, typename To> struct TCopyReference<From&, To > { using Type = To&; };
|
||||||
|
template <typename From, typename To> struct TCopyReference<From&&, To > { using Type = To&&; };
|
||||||
|
|
||||||
|
template <typename From, typename To> struct TCopyCVRef { using Type = typename TCopyCV<From, To>::Type; };
|
||||||
|
template <typename From, typename To> struct TCopyCVRef<From, To& > { using Type = typename TCopyCV<From, To>::Type&; };
|
||||||
|
template <typename From, typename To> struct TCopyCVRef<From, To&&> { using Type = typename TCopyCV<From, To>::Type&&; };
|
||||||
|
template <typename From, typename To> struct TCopyCVRef<From&, To > { using Type = typename TCopyCV<From, To>::Type&; };
|
||||||
|
template <typename From, typename To> struct TCopyCVRef<From&, To& > { using Type = typename TCopyCV<From, To>::Type&; };
|
||||||
|
template <typename From, typename To> struct TCopyCVRef<From&, To&&> { using Type = typename TCopyCV<From, To>::Type&; };
|
||||||
|
template <typename From, typename To> struct TCopyCVRef<From&&, To > { using Type = typename TCopyCV<From, To>::Type&&; };
|
||||||
|
template <typename From, typename To> struct TCopyCVRef<From&&, To& > { using Type = typename TCopyCV<From, To>::Type&; };
|
||||||
|
template <typename From, typename To> struct TCopyCVRef<From&&, To&&> { using Type = typename TCopyCV<From, To>::Type&&; };
|
||||||
|
|
||||||
|
NAMESPACE_MODULE_END(Utility)
|
||||||
|
NAMESPACE_MODULE_END(Redcraft)
|
||||||
|
NAMESPACE_REDCRAFT_END
|
@ -9,3 +9,4 @@
|
|||||||
#include "TypeTraits/Miscellaneous.h"
|
#include "TypeTraits/Miscellaneous.h"
|
||||||
#include "TypeTraits/Swappable.h"
|
#include "TypeTraits/Swappable.h"
|
||||||
#include "TypeTraits/Common.h"
|
#include "TypeTraits/Common.h"
|
||||||
|
#include "TypeTraits/CopyQualifiers.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user