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 

Template Parameter Forwarding

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





PostPosted: Sun Apr 17, 2005 2:26 pm    Post subject: Template Parameter Forwarding Reply with quote



There is a small proble I tried to solve.

Imagine this template(it's just an example):

template <typename T,typename T::type>
struct Something;

Now,everything is OK.

But imagine I want to default the first parameter,e.g. to some
metafunction.

To be able to default it,it must be at the end of the template parameter
list.

To be able to use it in the second parameter type,it must be at the front.
Nothing I tried seems to work,even traits.

Is there anything I could do in this situation?
Thanx. :-)



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Carl Barron
Guest





PostPosted: Sun Apr 17, 2005 9:20 pm    Post subject: Re: Template Parameter Forwarding Reply with quote



υα <efim.slobodov233432 (AT) arcor (DOT) de> wrote:

Quote:
There is a small proble I tried to solve.

Imagine this template(it's just an example):

template <typename T,typename T::type
struct Something;

Now,everything is OK.

But imagine I want to default the first parameter,e.g. to some
metafunction.

To be able to default it,it must be at the end of the template parameter
list.

To be able to use it in the second parameter type,it must be at the front.
Nothing I tried seems to work,even traits.

Is there anything I could do in this situation?
Thanx. :-)


Use inheritance like this:

template struct*/};

template <class T,class T::type> struct
something:something_base<T,T::type>
{ /* forwarding constructors */|;

template <> struct something
<
default_type,
default_type::type
Quote:
:something_base default_type::type

{ /* forwarding constructors */};




[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Ralph Zhang
Guest





PostPosted: Mon Apr 18, 2005 9:10 am    Post subject: Re: Template Parameter Forwarding Reply with quote



why don't you just move that T::type into the class? like this:

template<typename T>
struct Something
{
typedef typename T::type type;
};


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
υα
Guest





PostPosted: Mon Apr 18, 2005 3:14 pm    Post subject: Re: Template Parameter Forwarding Reply with quote


"> why don't you just move that T::type into the class? like this:
Quote:

template struct Something
{
typedef typename T::type type;
};

Because I want that it is defaultable,but at the same time
specifiable( Smile ).

Thanks for the answer,but just like I said,it wouldn't be nice if I had to
specify the default template parameters.



[ 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.