Template typedef.

J

JC

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top