Template as an argument to a class

R

Richard Cromer

Greetings,

I am trying to create a template class called Matrix that operates on a
template class called complex.

Now of course complex is a template class and I want it to be the argument
for Matrix.

So I have something like:
template <class T> class complex {/*..*/}

then I want to use complex in Matrix like this:
template <class T2> class Matrix {/*..*/} where T2 is of type
complex<double>.

Has anyone ever done anything like that? I am using Solaris 2.6 OS with CC
ver 6.2.

Any help will be appreciated.

Thanks.
 
A

Attila Feher

Richard said:
Greetings,

I am trying to create a template class called Matrix that operates on
a template class called complex.

Now of course complex is a template class and I want it to be the
argument for Matrix.

So I have something like:
template <class T> class complex {/*..*/}

then I want to use complex in Matrix like this:
template <class T2> class Matrix {/*..*/} where T2 is of type
complex<double>.

Has anyone ever done anything like that? I am using Solaris 2.6 OS
with CC ver 6.2.

I think you will need template template parameters. I am not sure if Forte
6.2 supports it.
 
T

tom_usenet

Greetings,

I am trying to create a template class called Matrix that operates on a
template class called complex.

Now of course complex is a template class and I want it to be the argument
for Matrix.

So I have something like:
template <class T> class complex {/*..*/}

then I want to use complex in Matrix like this:
template <class T2> class Matrix {/*..*/} where T2 is of type
complex<double>.

Has anyone ever done anything like that? I am using Solaris 2.6 OS with CC
ver 6.2.

Matrix<complex<double>/*note a space is required*/> m;
e.g.
Matrix<complex<double> > m;


Matrix<complex<double>> m;
is a syntax error, since the last >> is a right shift operator, where
you need two > tokens instead. This is considered a major problem with
the C++ "max munch" parsing (which grabs the biggest token available),
but there is an intention to fix it for the next version of the C++
standard.

Tom
 

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

Forum statistics

Threads
474,141
Messages
2,570,813
Members
47,357
Latest member
sitele8746

Latest Threads

Top