New transparent workaround for Field-Functions

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@119 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
humesikkins 2003-03-08 13:00:42 +00:00
parent 979f972d74
commit d4645ccd07

View file

@ -13,7 +13,7 @@
// without express or implied warranty. // without express or implied warranty.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Last update: Dec 08, 2002 // Last update: Mar 08, 2003
#ifndef HIERARCHYGENERATORS_INC_ #ifndef HIERARCHYGENERATORS_INC_
@ -211,14 +211,14 @@ namespace Private
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class T, class TList, class UnitWrapper> template <class T, class TList, class UnitWrapper>
typename ApplyInnerType<UnitWrapper, T>::type& typename ApplyInnerType<UnitWrapper, T>::type&
Field(GenScatterHierarchy<TList, UnitWrapper>& obj) Field(GenScatterHierarchy<TList, UnitWrapper>& obj,Type2Type<T>* = (Type2Type<T>*)0)
{ {
return obj; return obj;
} }
template <class T, class TList, class UnitWrapper> template <class T, class TList, class UnitWrapper>
const typename ApplyInnerType<UnitWrapper, T>::type& const typename ApplyInnerType<UnitWrapper, T>::type&
Field(const GenScatterHierarchy<TList, UnitWrapper>& obj) Field(const GenScatterHierarchy<TList, UnitWrapper>& obj, Type2Type<T>* = (Type2Type<T>*)0)
{ {
return obj; return obj;
} }
@ -372,6 +372,7 @@ namespace Private
// returns a reference to Unit<T>, where Unit is the template used to generate H // returns a reference to Unit<T>, where Unit is the template used to generate H
// and T is the i-th type in the typelist // and T is the i-th type in the typelist
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/*
template <unsigned int i, class TList, class UnitWrapper> template <unsigned int i, class TList, class UnitWrapper>
typename FieldHelper<i>::template In<GenScatterHierarchy<TList, UnitWrapper>,UnitWrapper>::ResultType& typename FieldHelper<i>::template In<GenScatterHierarchy<TList, UnitWrapper>,UnitWrapper>::ResultType&
Field(GenScatterHierarchy<TList, UnitWrapper>& obj, Int2Type<i>) Field(GenScatterHierarchy<TList, UnitWrapper>& obj, Int2Type<i>)
@ -379,7 +380,14 @@ namespace Private
typedef typename GenScatterHierarchy<TList, UnitWrapper> H; typedef typename GenScatterHierarchy<TList, UnitWrapper> H;
return FieldHelper<i>::template In<H, UnitWrapper>::Do(obj, (int*)0); return FieldHelper<i>::template In<H, UnitWrapper>::Do(obj, (int*)0);
} }
*/
template <unsigned int i, class TList, class UnitWrapper>
typename FieldHelper<i>::template In<GenScatterHierarchy<TList, UnitWrapper>,UnitWrapper>::ResultType&
Field(GenScatterHierarchy<TList, UnitWrapper>& obj, Int2Type<i>* = (Int2Type<i>*)0)
{
typedef typename GenScatterHierarchy<TList, UnitWrapper> H;
return FieldHelper<i>::template In<H, UnitWrapper>::Do(obj, (int*)0);
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template GenLinearHierarchy // class template GenLinearHierarchy
// Generates a linear hierarchy starting from a typelist and a template // Generates a linear hierarchy starting from a typelist and a template
@ -487,7 +495,7 @@ namespace Private
#if defined (_MSC_VER) && _MSC_VER <= 1300 #if defined (_MSC_VER) && _MSC_VER <= 1300
#define FIELD(Obj, Nr) \ #define FIELD(Obj, Nr) \
Field(Obj, Int2Type<Nr>()) Field(Obj, (Int2Type<Nr>*)0)
#else #else
#define FIELD(Obj, Nr) \ #define FIELD(Obj, Nr) \
Field<Nr>(Obj) Field<Nr>(Obj)
@ -505,6 +513,8 @@ namespace Private
// work correctly due to the "Explicitly Specified Template // work correctly due to the "Explicitly Specified Template
// Functions Not Overloaded Correctly"-Bug // Functions Not Overloaded Correctly"-Bug
// (Microsoft KB Article - 240871). B.K. // (Microsoft KB Article - 240871). B.K.
// Mar 08, 2003: New transparent workaround for Field-Functions. The FIELD-Macro
// is no longer needed. B.K.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#undef IS_TYPELIST #undef IS_TYPELIST
#endif // HIERARCHYGENERATORS_INC_ #endif // HIERARCHYGENERATORS_INC_