Boost logo

Boost :

From: Terence Wilson (tez_at_[hidden])
Date: 2002-06-17 20:11:38

Thanks David,

I actually had the cast syntax right, however, I had mismatched the
return type. I double-checked after reading your message and found the
error. It now compiles.

-----Original Message-----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]] On Behalf Of David Abrahams
Sent: Monday, June 17, 2002 5:21 PM
To: boost_at_[hidden]
Subject: Re: [boost] Quickie- How to use bind with an overloaded member?

From: "Terence Wilson" <tez_at_[hidden]>

> Given a class:
> class Thing
> {
> ...
> DoIt(int x);
> DoIt(std::string str);
> }

Hmm, what are the return types?

> Here is my (incorrect) code for calling DoIt with every string in
> myVec:
> Thing myThing;
> std::vector myVec;
> std::for_each(myVec.begin(), myVec.end(), boost::bind(&Thing::DoIt,
> &myThing, _1));
> The sticking point seems to be the overloaded DoIt. How do I clear up
> the ambiguity?
You gotta cast :(

    (R (Thing::*)(int))&Thing::DoIt


    (R (Thing::*)(std::string))&Thing::DoIt

Where R is the return type.


Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at