Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-06-17 19:21:23


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

or

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

Where R is the return type.

-D


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