Velocity Reviews - Computer Hardware Reviews

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

Thread Tools

Template typedef.

Posts: n/a
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

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;

Reply With Quote
Victor Bazarov
Posts: n/a
JC wrote:
> [..]
> I'm trying to make typedefs for some of the more common cases. [..]

Search the archives (using for "template
typedefs", and you shall find.

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

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