Default template function objects

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::eek: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
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top