diff --git a/include/loki/TypeTraits.h b/include/loki/TypeTraits.h index 70867b2..d8f24d2 100644 --- a/include/loki/TypeTraits.h +++ b/include/loki/TypeTraits.h @@ -72,6 +72,16 @@ namespace Loki StdOtherInts; typedef TYPELIST_3(float, double, long double) StdFloats; + + template struct AddPointer + { + typedef U* Result; + }; + + template struct AddPointer + { + typedef U* Result; + }; template struct AddReference { @@ -102,8 +112,1883 @@ namespace Loki { typedef NullType Result; }; - - } + + template + struct IsFunctionPointerRaw + {enum{result = 0};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsFunctionPointerRaw + {enum {result = 1};}; + + + template + struct IsMemberFunctionPointerRaw + {enum{result = 0};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + // Const versions + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + // Volatile versions + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + // Const volatile versions + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + template + struct IsMemberFunctionPointerRaw + {enum {result = 1};}; + + }// namespace Private //////////////////////////////////////////////////////////////////////////////// // class template TypeTraits @@ -147,6 +2032,19 @@ namespace Loki class TypeTraits { private: + + template struct ReferenceTraits + { + enum { result = false }; + typedef U ReferredType; + }; + + template struct ReferenceTraits + { + enum { result = true }; + typedef U ReferredType; + }; + template struct PointerTraits { enum { result = false }; @@ -164,19 +2062,7 @@ namespace Loki enum { result = true }; typedef U PointeeType; }; - - template struct ReferenceTraits - { - enum { result = false }; - typedef U ReferredType; - }; - - template struct ReferenceTraits - { - enum { result = true }; - typedef U ReferredType; - }; - + template struct PToMTraits { enum { result = false }; @@ -192,6 +2078,16 @@ namespace Loki enum { result = true }; }; + template struct FunctionPointerTraits + { + enum{ result = Private::IsFunctionPointerRaw::result }; + }; + + template struct PToMFunctionTraits + { + enum{ result = Private::IsMemberFunctionPointerRaw::result }; + }; + template struct UnConst { typedef U Result; @@ -227,7 +2123,6 @@ namespace Loki typedef U& Result; enum { isVolatile = 1 }; }; - public: typedef typename UnConst::Result @@ -243,23 +2138,33 @@ namespace Loki enum { isConst = UnConst::isConst }; enum { isVolatile = UnVolatile::isVolatile }; - enum { isPointer = PointerTraits::result }; enum { isReference = ReferenceTraits::result }; - enum { isMemberPointer = PToMTraits::result }; + enum { isFunction = FunctionPointerTraits::Result >::result }; + enum { isFunctionPointer= FunctionPointerTraits< + typename ReferenceTraits::ReferredType >::result }; + enum { isMemberFunctionPointer= PToMFunctionTraits< + typename ReferenceTraits::ReferredType >::result }; + enum { isMemberPointer = PToMTraits< + typename ReferenceTraits::ReferredType >::result || + isMemberFunctionPointer }; + enum { isPointer = PointerTraits< + typename ReferenceTraits::ReferredType >::result || + isFunctionPointer || isMemberPointer }; + enum { isStdUnsignedInt = TL::IndexOf::value >= 0 || TL::IndexOf::ReferredType>::value >= 0}; + typename ReferenceTraits::ReferredType>::value >= 0}; enum { isStdSignedInt = TL::IndexOf::value >= 0 || TL::IndexOf::ReferredType>::value >= 0}; + typename ReferenceTraits::ReferredType>::value >= 0}; enum { isStdIntegral = isStdUnsignedInt || isStdSignedInt || TL::IndexOf::value >= 0 || TL::IndexOf::ReferredType>::value >= 0}; + typename ReferenceTraits::ReferredType>::value >= 0}; enum { isStdFloat = TL::IndexOf::value >= 0 || TL::IndexOf::ReferredType>::value >= 0}; + typename ReferenceTraits::ReferredType>::value >= 0}; enum { isStdArith = isStdIntegral || isStdFloat }; enum { isStdFundamental = isStdArith || isStdFloat || Conversion::sameType }; @@ -271,11 +2176,11 @@ namespace Loki enum { isFundamental = isStdFundamental || isArith || isFloat }; typedef typename Select::Result>::Result + typename Private::AddReference::Result>::Result ParameterType; typedef typename Select::Result>::Result + typename Private::AddConstReference::Result>::Result ConstParameterType; }; diff --git a/tools/RegressionTest/TypeTraitsTest2.h b/tools/RegressionTest/TypeTraitsTest2.h index 77055a0..8648ab2 100755 --- a/tools/RegressionTest/TypeTraitsTest2.h +++ b/tools/RegressionTest/TypeTraitsTest2.h @@ -106,7 +106,7 @@ #include #include -//#define ENABLE_ADDITIONAL_TYPETRAITS +#define ENABLE_ADDITIONAL_TYPETRAITS #include @@ -383,13 +383,12 @@ inline void TypeTraitsTest2::testPointer() PASS(void (* const volatile)(int, float)); PASS(void (* const volatile)(int, float, ...)); - /* - // Pointer to member functions + PASS(void (A::* const volatile)() const volatile); PASS(void (A::* const volatile)(int, float) const volatile); PASS(void (A::* const volatile)(int, float, ...) const volatile); PASS(int A::* const volatile); - */ + PASS(const volatile int** const volatile ** const * const volatile); PASS(int* const volatile&); @@ -407,7 +406,7 @@ inline void TypeTraitsTest2::testMemberPointer() PASS(int A::* const volatile); PASS(const volatile int A::* const volatile); - /* + // Pointer to member functions PASS(int (A::* )() const); PASS(int (A::* const volatile)() const volatile); @@ -415,7 +414,7 @@ inline void TypeTraitsTest2::testMemberPointer() PASS(int (A::* const volatile&)(int, float) const volatile); PASS(int (A::* const volatile)(int, float, ...) const volatile); PASS(int (A::* const volatile&)(int, float, ...) const volatile); - */ + FAIL(int); FAIL(void); @@ -429,6 +428,7 @@ inline void TypeTraitsTest2::testFunctionPointer() #undef CONDITION #define CONDITION isFunctionPointer + PASS(void (*)()); FAIL(void (A::* const volatile)()); FAIL(void (A::* const volatile)() const); FAIL(void (A::* const volatile)() volatile); @@ -446,6 +446,7 @@ inline void TypeTraitsTest2::testFunctionPointer() FAIL(void); FAIL(void*); FAIL(int A::*); + #endif }