C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Something about GenScatterHierarchy in Modern C++ Design....

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
lfeiman888@gmail.com
Guest





PostPosted: Fri Nov 11, 2005 9:15 am    Post subject: Something about GenScatterHierarchy in Modern C++ Design.... Reply with 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<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





PostPosted: Sat Nov 12, 2005 10:32 am    Post subject: Re: Something about GenScatterHierarchy in Modern C++ Design Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.