fix bug: [ 669669 ] TypeTraits::ParameterType for non-primitive types

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@209 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
syntheticpp 2005-08-26 15:07:24 +00:00
parent 41536265e8
commit 205770826b
2 changed files with 23 additions and 2 deletions

View file

@ -87,6 +87,22 @@ namespace Loki
{ {
typedef NullType Result; typedef NullType Result;
}; };
template <class U> struct AddConstReference
{
typedef const U & Result;
};
template <class U> struct AddConstReference<U &>
{
typedef const U & Result;
};
template <> struct AddConstReference<void>
{
typedef NullType Result;
};
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -232,9 +248,13 @@ namespace Loki
enum { isArith = isIntegral || isFloat }; enum { isArith = isIntegral || isFloat };
enum { isFundamental = isStdFundamental || isArith || isFloat }; enum { isFundamental = isStdFundamental || isArith || isFloat };
typedef typename Select<isStdArith || isPointer || isMemberPointer,T, typedef typename Select<isStdArith || isPointer || isMemberPointer, T,
typename Private::AddReference<T>::Result>::Result typename Private::AddReference<T>::Result>::Result
ParameterType; ParameterType;
typedef typename Select<isStdArith || isPointer || isMemberPointer, T,
typename Private::AddConstReference<T>::Result>::Result
ConstParameterType;
}; };
} }

View file

@ -104,7 +104,8 @@ public:
SameType<TypeTraits<char>::ParameterType,char>::value && SameType<TypeTraits<char>::ParameterType,char>::value &&
SameType<TypeTraits<int>::ParameterType,int>::value && SameType<TypeTraits<int>::ParameterType,int>::value &&
SameType<TypeTraits<double>::ParameterType,double>::value && SameType<TypeTraits<double>::ParameterType,double>::value &&
SameType<TypeTraits<Test>::ParameterType,Test &>::value; SameType<TypeTraits<Test>::ParameterType,Test &>::value &&
SameType<TypeTraits<Test>::ConstParameterType,const Test &>::value;
testAssert("TypeTraits",r,result); testAssert("TypeTraits",r,result);