Boost logo

Boost :

From: Stjepan Rajko (stipe_at_[hidden])
Date: 2008-03-12 17:00:11


On Wed, Mar 12, 2008 at 1:45 PM, Robert Dailey <rcdailey_at_[hidden]> wrote:
> Hi,
>
> I wish to use boost::bind to simply wrap a member function pointer. I'm
> passing a member function into a slot in the Boost.Signals library, and I
> would like the convenience of not having to specify the number of arguments
> each member function has in boost.bind. For example, assume I have the
> following class:
>
> class Foo
> {
> public:
> void Function1( int ) {}
> void Function2( int, int, bool ) {}
> };
>
>
> I would like to be able to do the following:
>
> Foo myFoo;
> boost::bind( &Foo::Function1, myFoo );
>
> In the case above, I now have an object bound to my function pointer,
> however I am required to explicitly place a _1, _2, _3 (etc) depending on
> how many parameters the member function takes. Is there a way that this can
> be automated? Thanks.

Please see:

http://dancinghacker.com/code/dataflow/dataflow/utility/bind_mem_fn.html

Regards,

Stjepan


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