 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
lfeiman888@gmail.com Guest
|
Posted: Fri Nov 11, 2005 9:15 am Post subject: Something about GenScatterHierarchy in Modern C++ Design.... |
|
|
I saw in Loki 's source code HierarchyGenerators.h
the Following code:
template <class T1, class T2, template
class GenScatterHierarchy<Typelist
: public GenScatterHierarchy<Private::ScatterHierarchyTag
T2>, Unit>
, public GenScatterHierarchy<T2, Unit>
{
public:
typedef Typelist<T1, T2> TList;
// Insure that LeftBase is unique and therefore reachable
typedef GenScatterHierarchy<Private::ScatterHierarchyTag
T2>, Unit> LeftBase;
typedef GenScatterHierarchy<T2, Unit> RightBase;
template <typename T> struct Rebind
{
typedef Unit<T> Result;
};
};
I wonder where does the T come from and what does mean???
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Lars Jordan Guest
|
Posted: Sat Nov 12, 2005 10:32 am Post subject: Re: Something about GenScatterHierarchy in Modern C++ Design |
|
|
Hi,
| Quote: | I saw in Loki 's source code HierarchyGenerators.h
the Following code:
template <class T1, class T2, template
class GenScatterHierarchy<Typelist
: public GenScatterHierarchy<Private::ScatterHierarchyTag
T2>, Unit
, public GenScatterHierarchy<T2, Unit
{
public:
typedef Typelist
// Insure that LeftBase is unique and therefore reachable
typedef GenScatterHierarchy<Private::ScatterHierarchyTag
T2>, Unit> LeftBase;
typedef GenScatterHierarchy<T2, Unit> RightBase;
template <typename T> struct Rebind
{
typedef Unit<T> Result;
};
};
I wonder where does the T come from and what does mean???
|
You have to see the
template <typename T> struct Rebind
{
typedef Unit<T> Result;
};
all together. This is a member class template. T is a new type parameter for
this member template. If you look further down the header you'll notice that it
is used in the implementation of the Field function template to generate the
appropriate return type. This will have Field cast the reference specified as
parameter to the appropriate sub object type and return a reference to it.
It's the same how often I'm having a look at this code - for me it's the gist of
the book. Thanks, Mr. Alexandrescu.
regards
Lars
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|