diff --git a/octa/type_traits.h b/octa/type_traits.h index 3479a50..1316815 100644 --- a/octa/type_traits.h +++ b/octa/type_traits.h @@ -24,8 +24,26 @@ namespace octa { template struct __OctaCommonType; + template + using RemoveCv = typename __OctaRemoveCv::Type; + + template + using AddLvalueReference = typename __OctaAddLr::Type; + + template + using AddRvalueReference = typename __OctaAddRr::Type; + + template + using AddConst = typename __OctaAddConst::Type; + + template + using RemoveReference = typename __OctaRemoveReference::Type; + + template + using RemoveAllExtents = typename __OctaRemoveAllExtents::Type; + /* declval also defined here to avoid including utility.h */ - template typename __OctaAddRr::Type __octa_declval(); + template AddRvalueReference __octa_declval(); /* integral constant */ @@ -51,16 +69,15 @@ namespace octa { template< > struct __OctaIsVoid: True {}; template - struct IsVoid: __OctaIsVoid::Type> {}; + struct IsVoid: __OctaIsVoid> {}; /* is null pointer */ template struct __OctaIsNullPointer : False {}; template< > struct __OctaIsNullPointer: True {}; - template struct IsNullPointer: __OctaIsNullPointer< - typename __OctaRemoveCv::Type - > {}; + template struct IsNullPointer: + __OctaIsNullPointer> {}; /* is integer */ @@ -84,7 +101,7 @@ namespace octa { template<> struct __OctaIsIntegral< wchar_t>: True {}; template - struct IsIntegral: __OctaIsIntegral::Type> {}; + struct IsIntegral: __OctaIsIntegral> {}; /* is floating point */ @@ -95,7 +112,7 @@ namespace octa { template<> struct __OctaIsFloatingPoint: True {}; template - struct IsFloatingPoint: __OctaIsFloatingPoint::Type> {}; + struct IsFloatingPoint: __OctaIsFloatingPoint> {}; /* is array */ @@ -109,7 +126,7 @@ namespace octa { template struct __OctaIsPointer: True {}; template - struct IsPointer: __OctaIsPointer::Type> {}; + struct IsPointer: __OctaIsPointer> {}; /* is lvalue reference */ @@ -182,9 +199,7 @@ namespace octa { struct __OctaIsMemberPointer: True {}; template - struct IsMemberPointer: __OctaIsMemberPointer< - typename __OctaRemoveCv::Type - > {}; + struct IsMemberPointer: __OctaIsMemberPointer> {}; /* is pointer to member object */ @@ -197,7 +212,7 @@ namespace octa { > {}; template struct IsMemberObjectPointer: - __OctaIsMemberObjectPointer::Type> {}; + __OctaIsMemberObjectPointer> {}; /* is pointer to member function */ @@ -210,7 +225,7 @@ namespace octa { > {}; template struct IsMemberFunctionPointer: - __OctaIsMemberFunctionPointer::Type> {}; + __OctaIsMemberFunctionPointer> {}; /* is reference */ @@ -284,7 +299,7 @@ namespace octa { template struct IsTriviallyCopyable: IntegralConstant::Type>::value + IsScalar>::value > {}; /* is trivial */ @@ -301,7 +316,7 @@ namespace octa { /* is constructible */ -#define __OCTA_MOVE(v) static_cast::Type &&>(v) +#define __OCTA_MOVE(v) static_cast &&>(v) template struct __OctaSelect2nd { typedef T Type; }; struct __OctaAny { __OctaAny(...); }; @@ -374,9 +389,7 @@ namespace octa { /* array types are default constructible if their element type is */ template - struct __OctaCtibleCore: __OctaCtible< - typename __OctaRemoveAllExtents::Type - > {}; + struct __OctaCtibleCore: __OctaCtible> {}; /* otherwise array types are not constructible by this syntax */ template @@ -396,13 +409,13 @@ namespace octa { /* is copy constructible */ template struct IsCopyConstructible: IsConstructible::Type>::Type + AddLvalueReference> > {}; /* is move constructible */ template struct IsMoveConstructible: IsConstructible::Type + AddRvalueReference > {}; /* is assignable */ @@ -427,15 +440,15 @@ namespace octa { /* is copy assignable */ template struct IsCopyAssignable: IsAssignable< - typename __OctaAddLr::Type, - typename __OctaAddLr::Type>::Type + AddLvalueReference, + AddLvalueReference> > {}; /* is move assignable */ template struct IsMoveAssignable: IsAssignable< - typename __OctaAddLr::Type, - const typename __OctaAddRr::Type + AddLvalueReference, + const AddRvalueReference > {}; /* is destructible */ @@ -456,7 +469,7 @@ namespace octa { template struct __OctaDtibleImpl: IntegralConstant::Type>::value + IsDestructorWellformed>::value > {}; template @@ -509,14 +522,14 @@ namespace octa { template struct IsTriviallyCopyConstructible: IsTriviallyConstructible::Type + AddLvalueReference > {}; /* is trivially move constructible */ template struct IsTriviallyMoveConstructible: IsTriviallyConstructible::Type + AddRvalueReference > {}; /* is trivially assignable */ @@ -548,14 +561,14 @@ namespace octa { template struct IsTriviallyCopyAssignable: IsTriviallyAssignable::Type + AddLvalueReference > {}; /* is trivially move assignable */ template struct IsTriviallyMoveAssignable: IsTriviallyAssignable::Type + AddRvalueReference > {}; /* is trivially destructible */ @@ -599,14 +612,14 @@ namespace octa { template struct IsNothrowCopyConstructible: IsNothrowConstructible::Type + AddLvalueReference > {}; /* is nothrow move constructible */ template struct IsNothrowMoveConstructible: IsNothrowConstructible::Type + AddRvalueReference > {}; /* is nothrow assignable */ @@ -638,14 +651,14 @@ namespace octa { template struct IsNothrowCopyAssignable: IsNothrowAssignable::Type + AddLvalueReference > {}; /* is nothrow move assignable */ template struct IsNothrowMoveAssignable: IsNothrowAssignable::Type + AddRvalueReference > {}; /* is nothrow destructible */ @@ -746,57 +759,50 @@ namespace octa { template struct __OctaRemoveVolatile { typedef T Type; }; - template - struct __OctaRemoveCv { - typedef typename __OctaRemoveVolatile< - typename __OctaRemoveConst::Type - >::Type Type; - }; - template using RemoveConst = typename __OctaRemoveConst::Type; template using RemoveVolatile = typename __OctaRemoveVolatile::Type; + template - using RemoveCv = typename __OctaRemoveCv::Type; + struct __OctaRemoveCv { + typedef RemoveVolatile> Type; + }; /* add const, volatile, cv */ template::value || IsFunction::value || IsConst::value> - struct __Octa__OctaAddConst { typedef T Type; }; + struct __OctaAddConstBase { typedef T Type; }; - template struct __Octa__OctaAddConst { + template struct __OctaAddConstBase { typedef const T Type; }; template struct __OctaAddConst { - typedef typename __Octa__OctaAddConst::Type Type; + typedef typename __OctaAddConstBase::Type Type; }; template::value || IsFunction::value || IsVolatile::value> - struct __Octa__OctaAddVolatile { typedef T Type; }; + struct __OctaAddVolatileBase { typedef T Type; }; - template struct __Octa__OctaAddVolatile { + template struct __OctaAddVolatileBase { typedef volatile T Type; }; template struct __OctaAddVolatile { - typedef typename __Octa__OctaAddVolatile::Type Type; + typedef typename __OctaAddVolatileBase::Type Type; }; + template + using AddVolatile = typename __OctaAddVolatile::Type; + template struct __OctaAddCv { - typedef typename __OctaAddConst< - typename __OctaAddVolatile::Type - >::Type Type; + typedef AddConst> Type; }; - template - using AddConst = typename __OctaAddConst::Type; - template - using AddVolatile = typename __OctaAddVolatile::Type; template using AddCv = typename __OctaAddCv::Type; @@ -809,9 +815,6 @@ namespace octa { template struct __OctaRemoveReference { typedef T Type; }; - template - using RemoveReference = typename __OctaRemoveReference::Type; - /* remove pointer */ template @@ -831,7 +834,7 @@ namespace octa { /* add pointer */ template struct __OctaAddPointer { - typedef typename __OctaRemoveReference::Type *Type; + typedef RemoveReference *Type; }; template @@ -855,9 +858,6 @@ namespace octa { typedef const volatile void Type; }; - template - using AddLvalueReference = typename __OctaAddLr::Type; - /* add rvalue reference */ template struct __OctaAddRr { typedef T &&Type; }; @@ -876,9 +876,6 @@ namespace octa { typedef const volatile void Type; }; - template - using AddRvalueReference = typename __OctaAddRr::Type; - /* remove extent */ template @@ -896,16 +893,13 @@ namespace octa { template struct __OctaRemoveAllExtents { typedef T Type; }; template struct __OctaRemoveAllExtents { - typedef typename __OctaRemoveAllExtents::Type Type; + typedef RemoveAllExtents Type; }; template struct __OctaRemoveAllExtents { - typedef typename __OctaRemoveAllExtents::Type Type; + typedef RemoveAllExtents Type; }; - template - using RemoveAllExtents = typename __OctaRemoveAllExtents::Type; - /* make (un)signed * * this is bad, but i don't see any better way @@ -951,8 +945,8 @@ namespace octa { }; template::Type>::value, - bool = IsVolatile::Type>::value + bool = IsConst>::value, + bool = IsVolatile>::value > struct __OctaApplyCv { typedef U Type; }; @@ -1029,17 +1023,13 @@ namespace octa { template struct __OctaMakeSignedBase { typedef typename __OctaApplyCv::Type - >::Type + typename __OctaMakeSigned>::Type >::Type Type; }; template struct __OctaMakeUnsignedBase { typedef typename __OctaApplyCv::Type - >::Type + typename __OctaMakeUnsigned>::Type >::Type Type; }; @@ -1121,15 +1111,12 @@ namespace octa { template struct __OctaDecay { private: - typedef typename __OctaRemoveReference::Type U; + typedef RemoveReference U; public: - typedef typename __OctaConditional::value, - typename __OctaRemoveExtent::Type *, - typename __OctaConditional::value, - typename __OctaAddPointer::Type, - typename __OctaRemoveCv::Type - >::Type - >::Type Type; + typedef Conditional::value, + RemoveExtent *, + Conditional::value, AddPointer, RemoveCv> + > Type; }; template