Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-01-23 10:24:06


Edward Diener wrote:
> Sorry for the delay in answering this, as I was busy with other work.
>
> struct X { void AMemberFunction(int} };
> struct Y { void AnotherMemberFunction(int) { } };
>
> // Within some code
>
> X x;
> Y y;
> boost::function< void (int) > ACallback;
> ACallback = boost::bind(&X::AMemberFunction,&x) // or
> ACallback = boost::bind(&Y::AnotherMemberFunction,&y);

Yes, that's what I thought (you need to add a trailing _1 to forward the
'int' parameter as well). The plan is to support this. I asked for code
because your statement:

>>> The idea is this. I use boost::bind to assign a member function to
>>> boost::function. Later I want to check boost::function to see if my
>>> particular member function is the one it encapsulates as the
>>> callback.

in C++ reads:

function< void(X*, int) > callback( &X::AMemberFunction );

and you didn't really have that in mind, although equality comprasions for
the above case will be supported, too.

> Admittedly the check, and the reasons for doing so, are farfetched
> and I am using boost::bind merely to bind a member function to a
> boost::function for later callback without any argument substitution,

No, you do use argument substitution; you bind the implicit "this" parameter
to &x.


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