R
Rune Allnor
Hi all.
I am trying to implement a class for numerical work.
Prt of the functionality will be an accumulator, that is,
a scalar variable x that scales general data y on
the form (declarations below)
T x;
U y;
y*=x;
The type T is either a double or a float, whereas
the type U might be any numerical data type
(double, float, complex<>, vector, matrix,...).
I would like to set this up with default template
declarations so that if, say, T = U = double,
then double:perator*=(const double&) is invoked
by default.
I have attempted to set this up in terms of template
declarations, as several variations of this idea:
#include <boost/bind.hpp>
template<
class T,
class U = T,
class AccT = boost::bind(&operator+=,_1) // <<========class MyClass{
public:
private:
};
However, no matter what I try, I can't get the compiler
to accept the indicated line. Either there is a type argument
missing, or there is some other error.
So the question is if I am on th eright track, with only a detail
wrong, or if this is a blind alley with no hope of success?
Rune
I am trying to implement a class for numerical work.
Prt of the functionality will be an accumulator, that is,
a scalar variable x that scales general data y on
the form (declarations below)
T x;
U y;
y*=x;
The type T is either a double or a float, whereas
the type U might be any numerical data type
(double, float, complex<>, vector, matrix,...).
I would like to set this up with default template
declarations so that if, say, T = U = double,
then double:perator*=(const double&) is invoked
by default.
I have attempted to set this up in terms of template
declarations, as several variations of this idea:
#include <boost/bind.hpp>
template<
class T,
class U = T,
class AccT = boost::bind(&operator+=,_1) // <<========class MyClass{
public:
private:
};
However, no matter what I try, I can't get the compiler
to accept the indicated line. Either there is a type argument
missing, or there is some other error.
So the question is if I am on th eright track, with only a detail
wrong, or if this is a blind alley with no hope of success?
Rune