templated data member

D

Daniel L Elliott

Hello,

I want to have a class which can contain vectors of many different types
(int, double, Complex, etc).

Is it possible to have a generic vector inside a non-template class?

Thank you,

Dan Elliott
 
G

Gianni Mariani

Daniel said:
Hello,

I want to have a class which can contain vectors of many different types
(int, double, Complex, etc).

Is it possible to have a generic vector inside a non-template class?

How would you use the class ?

Perhaps boost::any is somthing like what you're looking for ?
 
D

Daniel L Elliott

How would you use the class ?

Perhaps boost::any is somthing like what you're looking for ?


Thank you for your response. Here is a brief description of my usage:

I have a set of transformations. Each is represented by a class which
contains a matrix (uBLAS) which may contain int,float,Complex,etc.
However, transformations are applied by passing images into the class and
therefore the data type of the internal matrix does not really matter.
Can I make the matrix data member generic (template) while not having a
template parameter for the matrix contents (int, float, Complex, etc.)?

Some tranformations are best represented as a matrix of integers while
others must be float. However, I would like them all to fall under the
same data type.

Thank you very much for all responses!

- dan
 
J

John Harrison

Can I make the matrix data member generic (template) while not having a
template parameter for the matrix contents (int, float, Complex, etc.)?

Can I make it generic, without making it generic? Of course the answer is
no.

As already suggested maybe boost::any is what you are looking for.
www.boost.org.

john
 

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,183
Messages
2,570,970
Members
47,527
Latest member
RoxanneTos

Latest Threads

Top