Boost logo

Boost :

From: ali f (k9eks_at_[hidden])
Date: 2006-12-08 16:07:11


Hi again,

ok, here's my actual real world situation:

win->on_mouse_move.connect(
    args_cast<2, bool(int,int,bool,int)>( (
        lambda::var(x) = lambda::_1,
        lambda::var(y) = lambda::_2,
        true
    ) )
    );

on_mouse_move is a boost.signal. I want to use lambda because it's a simple
thing to do. I just want to change some local variables according to where
the mouse moves in my window. on_mouse_move is called everytime there's a
mouse move (duh). So anyway, I can do the above with args_cast, I can't get
it working with bind:

win->on_mouse_move.connect(
    boost::bind( (
        lambda::var(x) = lambda::_1,
        lambda::var(y) = lambda::_2,
        true
    ), _1, _2 )
    );

I tried it with a templated function object call, ie the following works

template< class F > void call( F f ) {
    int a = 1, b = 2, c = 3, d = 4;
    //f( 1, 2, 3, 4 );
    f(a, b, c, d);
}

call( boost::bind( &draw, _1, _2 ) );

But it seems like it doesn't make sence or something...

----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
Newsgroups: gmane.comp.lib.boost.devel
Sent: Saturday, December 09, 2006 5:44 PM
Subject: Re: new utility: function parameter caster

Hervé Brönnimann wrote:

> Indeed, I tried and to my surprise it doesn't work (both boost::bind
> (&draw, _1, _2)(1,2,3,4) and boost::bind<void>(&draw, _1,
> _2)(1,2,3,4)).

Calling bind with (1, 2, 3, 4) doesn't work for you because of the rvalues.
It works with the latest CVS HEAD. You don't even need the & in front of
draw. boost::bind has been allowing extra arguments since day one.

_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost


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