|
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
or
(R (Thing::*)(std::string))&Thing::DoIt
Where R is the return type.
-D
_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk