diff --git a/Reference/HierarchyGenerators.h b/Reference/HierarchyGenerators.h index 2f40993..c8cd80f 100644 --- a/Reference/HierarchyGenerators.h +++ b/Reference/HierarchyGenerators.h @@ -39,17 +39,32 @@ namespace Loki // template 'Model' with the types contained in TList //////////////////////////////////////////////////////////////////////////////// + namespace Private + { + // The following type helps to overcome subtle flaw in the original + // implementation of GenScatterHierarchy. + // The flaw is revealed when the input type list of GenScatterHierarchy + // contains more then one element of the same type (e.g. TYPELIST_2(int, int)). + // In this case GenScatterHierarchy will contain multiple bases of the same + // type and some of them will not be reachable (per 10.3). + // For example before the fix the first element of Tuple + // is not reachable in any way! + template + struct ScatterHierarchyTag; + } + template class Unit> class GenScatterHierarchy; template class Unit> class GenScatterHierarchy, Unit> - : public GenScatterHierarchy + : public GenScatterHierarchy, Unit> , public GenScatterHierarchy { public: typedef Typelist TList; - typedef GenScatterHierarchy LeftBase; + // Insure that LeftBase is unique and therefore reachable + typedef GenScatterHierarchy, Unit> LeftBase; typedef GenScatterHierarchy RightBase; template struct Rebind { @@ -57,6 +72,13 @@ namespace Loki }; }; + // In the middle *unique* class that resolve possible ambiguity + template class Unit> + class GenScatterHierarchy, Unit> + : public GenScatterHierarchy + { + }; + template class Unit> class GenScatterHierarchy : public Unit { @@ -149,7 +171,7 @@ namespace Loki UnitType>::Result UnqualifiedResultType; typedef typename Select::Result ResultType; + UnqualifiedResultType>::Result ResultType; static ResultType& Do(H& obj) { @@ -179,7 +201,7 @@ namespace Loki UnitType>::Result UnqualifiedResultType; typedef typename Select::Result ResultType; + UnqualifiedResultType>::Result ResultType; static ResultType& Do(H& obj) {