R
Ruediger Knoerig
In my current project I used templates to provide an
universial interface to vector objects. For this purpose I declared
two methods with an additional template argument:
template<class Vector> void transform(const Vector &x)
template<class Vector> void inv_transform(Vector &x)
Doing it this way I can use it on all data containers
providing index array access via []:
Transform<float> T;
valarray<float> x(16);
float data[16];
float stream[64];
T.transform(x); // works
T.transform(data); // works too
T.inv_transform(x); // works
T.inv_transform(&stream[32]); // error: no matching function for call to
`StreamWaveletTransform<float, HaarFilterBank>:: inv_transform(float (*
[])'
candidates are: void StreamWaveletTransform<T,
FilterBank>::inv_transform(Vector&) [with Vector = float (*)[], T = float,
FilterBank = HaarFilterBank]
The problem is that the compiler won't take a "float *"
for an "float *&". If I do this conversion expilitly I get:
"conversion to non-const reference type `float*&' from rvalue of type
`float*'".
Any suggestions? :-(
universial interface to vector objects. For this purpose I declared
two methods with an additional template argument:
template<class Vector> void transform(const Vector &x)
template<class Vector> void inv_transform(Vector &x)
Doing it this way I can use it on all data containers
providing index array access via []:
Transform<float> T;
valarray<float> x(16);
float data[16];
float stream[64];
T.transform(x); // works
T.transform(data); // works too
T.inv_transform(x); // works
T.inv_transform(&stream[32]); // error: no matching function for call to
`StreamWaveletTransform<float, HaarFilterBank>:: inv_transform(float (*
[])'
candidates are: void StreamWaveletTransform<T,
FilterBank>::inv_transform(Vector&) [with Vector = float (*)[], T = float,
FilterBank = HaarFilterBank]
The problem is that the compiler won't take a "float *"
for an "float *&". If I do this conversion expilitly I get:
"conversion to non-const reference type `float*&' from rvalue of type
`float*'".
Any suggestions? :-(