Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Template typedef.

Reply
Thread Tools

Template typedef.

 
 
JC
Guest
Posts: n/a
 
      06-16-2009
I have two template classes:

template <typename X> class Simple { ... };

template <typename T, typename S> class Complex { ... };

The "Complex" class typically takes some Simple type as it's S
parameter, e.g.:

Complex<int, Simple<int> >

I'm trying to make typedefs for some of the more common cases. For
cases where the types are already known, it's easy (note that S is not
always a Simple<>, it can be anything,):

typedef Complex<int, Simple<int> > ComplexInt;
typedef Complex<Something, Another> ComplexSomething;

Is there a way to make something like a typedef for cases where T and
X are unknown but are the same type, and S is a Simple<T>, and still
have T be a template parameter? E.g. something like (I know this is
incorrect):

template <typename T> Complex<T, Simple<T> > ComplexGeneric;

So that later on all you need to do is this:

ComplexGeneric<int> g;

And it is equivalent to:

Complex<int, Simple<int> > g;

Thanks,
Jason
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      06-16-2009
JC wrote:
> [..]
> I'm trying to make typedefs for some of the more common cases. [..]


Search the archives (using http://groups.google.com) for "template
typedefs", and you shall find.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
r H2 deduce deduce template argument of a template class inheritingfrom a non template base? nguillot C++ 5 03-08-2009 05:56 PM
How to use the template member function of a template in the memberfunction of another template class? Peng Yu C++ 3 10-26-2008 03:51 PM
template template arguments: expected a class template, got `Component<T1, T2, T3> gary.bernstein@gmail.com C++ 1 06-08-2007 07:10 AM
Re: A Newbie Question about template template template tom_usenet C++ 0 07-24-2003 12:06 PM
Re: A Newbie Question about template template template Chris Theis C++ 2 07-24-2003 09:42 AM



Advertisments