Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-12-09 09:49:39


Hervé Brönnimann wrote:
> Peter: I tried
>
> #include <boost/bind.hpp>
> void draw(int, int) {}
>
> int main()
> {
> boost::bind<void>(&draw, _1, _2) (1, 2, 3, 4);
> return 0;
> }
>
> and that didn't compile. How did you mean this: "Yes it can"?

Try one of

1. Using the above with CVS HEAD (you don't need the <void> and the &, but
with works with them);

2. Passing lvalues:

int main()
{
    int a1 = 1, a2 = 2, a3 = 3, a4 = 4;
    boost::bind<void>(&draw, _1, _2) (a1, a2, a3, a4);
}

3. A real scenario:

int main()
{
    boost::function< void( int, int, int, int ) > callback =
        boost::bind( draw, _1, _2 );

    callback( 1, 2, 3, 4 );
}


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