Uses Reference if compiler has no port
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@48 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
0b9d261d9b
commit
ad7e89ad22
31 changed files with 509 additions and 470 deletions
|
@ -80,13 +80,13 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class T, class H>
|
||||
typename H::Rebind<T>::Result& Field(H& obj)
|
||||
typename H::template Rebind<T>::Result& Field(H& obj)
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
template <class T, class H>
|
||||
const typename H::Rebind<T>::Result& Field(const H& obj)
|
||||
const typename H::template Rebind<T>::Result& Field(const H& obj)
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ namespace Loki
|
|||
struct FieldHelper<H, 0>
|
||||
{
|
||||
typedef typename H::TList::Head ElementType;
|
||||
typedef typename H::Rebind<ElementType>::Result UnitType;
|
||||
typedef typename H::template Rebind<ElementType>::Result UnitType;
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ namespace Loki
|
|||
struct FieldHelper
|
||||
{
|
||||
typedef typename TL::TypeAt<typename H::TList, i>::Result ElementType;
|
||||
typedef typename H::Rebind<ElementType>::Result UnitType;
|
||||
typedef typename H::template Rebind<ElementType>::Result UnitType;
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -249,6 +249,7 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Change log:
|
||||
// June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
|
||||
// September 16, 2002: Fixed dependent template, using "::template" syntax. T.S.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // HIERARCHYGENERATORS_INC_
|
||||
|
|
|
@ -105,7 +105,7 @@ namespace Loki
|
|||
{
|
||||
typedef Private::ConversionHelper<T, U> H;
|
||||
#ifndef __MWERKS__
|
||||
enum { exists = sizeof(typename H::Small) == sizeof(H::Test(H::MakeT())) };
|
||||
enum { exists = sizeof(typename H::Small) == sizeof((H::Test(H::MakeT()))) };
|
||||
#else
|
||||
enum { exists = false };
|
||||
#endif
|
||||
|
@ -139,6 +139,22 @@ namespace Loki
|
|||
};
|
||||
} // namespace Loki
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class template SuperSubclass
|
||||
// Invocation: SuperSubclass<B, D>::value where B and D are types.
|
||||
// Returns true if B is a public base of D, or if B and D are aliases of the
|
||||
// same type.
|
||||
//
|
||||
// Caveat: might not work if T and U are in a private inheritance hierarchy.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class T, class U>
|
||||
struct SuperSubclass
|
||||
{
|
||||
enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists &&
|
||||
!::Loki::Conversion<const volatile T*, const volatile void*>::sameType) };
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// macro SUPERSUBCLASS
|
||||
// Invocation: SUPERSUBCLASS(B, D) where B and D are types.
|
||||
|
@ -146,6 +162,7 @@ namespace Loki
|
|||
// same type.
|
||||
//
|
||||
// Caveat: might not work if T and U are in a private inheritance hierarchy.
|
||||
// Deprecated: Use SuperSubclass class template instead.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define SUPERSUBCLASS(T, U) \
|
||||
|
@ -153,11 +170,28 @@ namespace Loki
|
|||
!::Loki::Conversion<const volatile T*, const volatile void*>::sameType)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// macro SUPERSUBCLASS
|
||||
// class template SuperSubclassStrict
|
||||
// Invocation: SuperSubclassStrict<B, D>::value where B and D are types.
|
||||
// Returns true if B is a public base of D.
|
||||
//
|
||||
// Caveat: might not work if T and U are in a private inheritance hierarchy.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class T,class U>
|
||||
struct SuperSubclassStrict
|
||||
{
|
||||
enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists &&
|
||||
!::Loki::Conversion<const volatile T*, const volatile void*>::sameType &&
|
||||
!::Loki::Conversion<const volatile T*, const volatile U*>::sameType) };
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// macro SUPERSUBCLASS_STRICT
|
||||
// Invocation: SUPERSUBCLASS(B, D) where B and D are types.
|
||||
// Returns true if B is a public base of D.
|
||||
//
|
||||
// Caveat: might not work if T and U are in a private inheritance hierarchy.
|
||||
// Deprecated: Use SuperSubclassStrict class template instead.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define SUPERSUBCLASS_STRICT(T, U) \
|
||||
|
@ -172,6 +206,12 @@ namespace Loki
|
|||
// (credit due to Brad Town)
|
||||
// November 23, 2001: (well it's 12:01 am) fixed bug in SUPERSUBCLASS - added
|
||||
// the volatile qualifier to be 100% politically correct
|
||||
// September 16, 2002: Changed "const volatile" to "const volatile *", to enable
|
||||
// conversion to succeed. Done earlier by MKH.
|
||||
// Added SuperSubclass and SuperSubclassStrict templates. The corresponding
|
||||
// macros are deprecated.
|
||||
// Added extra parenthesis in sizeof in Conversion, to disambiguate function
|
||||
// call from function declaration. T.S.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // TYPEMANIP_INC_
|
||||
|
|
|
@ -70,6 +70,21 @@ namespace Loki
|
|||
int, long int) StdSignedInts;
|
||||
typedef TYPELIST_3(bool, char, wchar_t) StdOtherInts;
|
||||
typedef TYPELIST_3(float, double, long double) StdFloats;
|
||||
|
||||
template <class U> struct AddReference
|
||||
{
|
||||
typedef U & Result;
|
||||
};
|
||||
|
||||
template <class U> struct AddReference<U &>
|
||||
{
|
||||
typedef U & Result;
|
||||
};
|
||||
|
||||
template <> struct AddReference<void>
|
||||
{
|
||||
typedef NullType Result;
|
||||
};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -216,8 +231,7 @@ namespace Loki
|
|||
enum { isFundamental = isStdFundamental || isArith || isFloat };
|
||||
|
||||
typedef typename Select<isStdArith || isPointer || isMemberPointer,
|
||||
T, ReferredType&>::Result
|
||||
ParameterType;
|
||||
T, typename Private::AddReference<T>::Result>::Result ParameterType;
|
||||
|
||||
enum { isConst = UnConst<T>::isConst };
|
||||
typedef typename UnConst<T>::Result NonConstType;
|
||||
|
@ -231,6 +245,8 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Change log:
|
||||
// June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
|
||||
// September 16, 2002: ParameterType fixed, as TypeTraits<void> made
|
||||
// ParameterType give error about reference to void. T.S.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // TYPETRAITS_INC_
|
||||
|
|
|
@ -664,10 +664,10 @@ namespace Loki
|
|||
|
||||
template <class TList> struct Reverse;
|
||||
|
||||
template <class T>
|
||||
struct Reverse< TYPELIST_1(T) >
|
||||
template <>
|
||||
struct Reverse<NullType>
|
||||
{
|
||||
typedef TYPELIST_1(T) Result;
|
||||
typedef NullType Result;
|
||||
};
|
||||
|
||||
template <class Head, class Tail>
|
||||
|
@ -700,7 +700,7 @@ namespace Loki
|
|||
typedef typename MostDerived<Tail, T>::Result Candidate;
|
||||
public:
|
||||
typedef typename Select<
|
||||
SUPERSUBCLASS(Candidate, Head),
|
||||
SuperSubclass<Candidate,Head>::value,
|
||||
Head, Candidate>::Result Result;
|
||||
};
|
||||
|
||||
|
@ -748,7 +748,10 @@ namespace Loki
|
|||
// Kevin Cline who sent the first actual fix)
|
||||
// May 13, 2002: TYPELIST_46 called TYPELIST_45 with only 44 parameters.
|
||||
// Credit due to Robert Minsk
|
||||
// September 16, 2002: Changed MostDerived to use the new SuperSubclass template
|
||||
// (rather than the SUPERSUBCLASS macro).
|
||||
// Minor fix in Reverse, adding support for empty lists, like all the other
|
||||
// algorithms. T.S.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // TYPELIST_INC_
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue