Boost logo

Boost :

From: Sergey Lukin (lukin.s.v_at_[hidden])
Date: 2006-02-13 07:57:53


Peter Dimov wrote:

>> boost::function<void(int)> f = boost::bind( DPC::Print1, &x, 2 );
>> t.async_wait( boost::bind( Component::Method1, &y, 10, f, &t ) );
>> or
>> t.async_wait( boost::bind( Component::Method1, &y, 10,
>> boost::protect(f), &t ) );
>
>Your Component::Method1 takes two arguments, three with the implicit 'this':
>
>class Component
>{
>public:
> template <typename Handler>
> void Method1 (int x ,Handler h)
> {
> x++;
> h();
> }
>};
>
>
>but you are passing four, there is one extra &t at the end.

Yes, you were right. I was passing not needed fifth parameter.
But anyway this haven't changed error messages much.
in both cases I am getting boost::bind errors
...expects 2 arguments - 4 provided
...expects 3 arguments - 4 provided
...expects 5 arguments - 4 provided
...expects 6 arguments - 4 provided
...
Note: I'm not getting ... any error message for the 4 argument case,
which is my case.
t.async_wait( boost::bind( &Component::Method1, &y, 10, f );
t.async_wait( boost::bind( &Component::Method1, &y, 10, boost::protect(f) );

>
>You should also use & with member functions, &Component::Method1, although
>some compilers allow you to omit it.

Jeff Flinn wrote:

>The types above are incompatible, use what Peter suggested previously:
>
>
> boost::function<void()> f = boost::bind( DPC::Print1, &x, 2 );

I tried this also - no effect whatsoever.

Have you tried to compile my code ?

Thank you in advance,
Sergey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk