$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Reece Dunn (msclrhd_at_[hidden])
Date: 2005-01-07 17:32:16
Brian Braatz wrote:
> With the following code, If you UNCOMMENT the "// public : Base" line,
> you get compiler errors (????)
>
> I have tested this with MS VC 7.1 against both 1.31 and 1.32 versions of
> boost with the same results.
>
> Any idea why this is happening? (full sample code I wrote is attached)
>[snip]
> std::string ReturnAString();
> [snip]
> bind(Base::ReturnAString,_1);
This is the problem. Try:
bind(Base::ReturnAString);
or:
bind(&Base::ReturnAString,this);
> My Compiler errors are this:
>
> c:\Data\Rmtg\Root\_Common\_Lib\Rmx\V_0_02\Exp\Src\LambdaProblem\Test_Lam
> bdaProblem.cpp(38) : error C2780: 'const
> boost::lambda::lambda_functor<... >
> boost::lambda::bind(...)' : expects 10 arguments - 2 provided
The error is misleading. I got a similar error when using Boost.Bind in
my GUI code. The basics of it is this: the arguments of bind(fn, ...)
must match to the arguments of the function *exactly*, using _n for
unspecified arguments. What this means is:
using boost::bind;
using boost::function;
class button
{
void draw( event * ev );
};
button btn;
function< ( event * ) > foo = bind(&button::draw,&btn); // [1]
foo = bind(&button::draw,&btn,_1); // _1 needed for the event * argument
[1] generates a similar error message to the one you get above.
Maybe this should be mentioned in the documentation somewhere.
HTH,
Reece