On 12 Jan 2006 16:46:45 -0800
"Lars Schouw" <sc******@yahoo.com> wrote:
typedef boost::function< double, X*, double, void* > tFnc;
give me:
c:\sletmig\templatedcallback\test.cpp(18) : error C2977:
'boost::function' : too many template arguments
c:\dev\boost\boost_1_33_1\boost\function\function_ base.hpp(92)
: see declaration of 'boost::function'
when I compile.... any idea?
Lars
That's because it's a mix between two notations. Thus you write either :
typedef boost::function< double (X*, double, void*) > tFnc;
but it does not work with all compiler (look at the boost::function
websites to know which compilers ...), or you use :
typedef boost::function3<double, X*, double, void*> tFct;
Now, if you want to store the function just use :
tFct fct = &X::f_cos; // No need to use bind !
However, if you want to use a zero argument function as a callback,
use :
boost::function<double> fct = boost::bind(&X::f_cox, x, somedbl,
someptr);
Then call :
double d = fct();
Also, you can bind part of the arguments using _1, _2, ... and the
correct function definition.
Pierre
--
You will have good luck and overcome many hardships.