A
Amadeus W. M.
Template member functions cannot be virtual - I know - but is there any
way to simulate that (other than making the entire class templated,
with non-templated members).
What I have is this:
class Transform
{
public:
// Each derived Transform should compute y=Transform(x)
// in its own way, so this operator() should be virtual,
// but I also want it to be templated on the vector type.
template <class Vector_t>
void operator()(const Vector_t & x, Vector_t & y) const {};
protected:
};
class Affine : public Transform
{
public:
template <class Vector_t>
void operator()(const Vector_t & x, Vector_t & y) const {
// real calculation of y=Affine(x).
}
private:
};
Similarly other Transform derived classes.
way to simulate that (other than making the entire class templated,
with non-templated members).
What I have is this:
class Transform
{
public:
// Each derived Transform should compute y=Transform(x)
// in its own way, so this operator() should be virtual,
// but I also want it to be templated on the vector type.
template <class Vector_t>
void operator()(const Vector_t & x, Vector_t & y) const {};
protected:
};
class Affine : public Transform
{
public:
template <class Vector_t>
void operator()(const Vector_t & x, Vector_t & y) const {
// real calculation of y=Affine(x).
}
private:
};
Similarly other Transform derived classes.