Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2004-01-22 22:23:30


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);

// Later I want to be able to check if ACallback's callback is x's
AMemberFunction or y's AnotherMemberFunction so:

if (ACallback == boost::bind(&X::AMemberFunction,&x))
{
// Do something
}
else if (ACallback == boost::bind(&Y::AnotherMemberFunction,&y))
{
// Do something else
}

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, but I am curious if this
sort of functionality is possible. If it were it would effectively let a
programmer check if the callback is coming to a particular object's member
function.

Peter Dimov wrote:
> Edward Diener wrote:
>> Peter Dimov wrote:
>>> ... I am not entirely sure that I understand the question.
>>
>> 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.
>
> Can you please illustrate this with code?


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