Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-05-03 08:40:00


Terence Wilson wrote:
> I have the following code:
>
> int val
> std::vector<std::string> ThingVec;
> std::for_each(ThingVec.begin(), ThingVec.end(), boost::bind(foo, val,
> _1));
>
> When foo has no overloads it compiles, otherwise I get a raft of
> compile errors from VC++ .Net 2003. Is there a way to explicity state
> the
> correct overload? Can bind handle overloaded functions?

C++ can't handle overloaded functions in such contexts. You can disambiguate
by taking the address of the function first:

void (*pf)(std::string) = &foo;

or by using a cast:

(void (*)(std::string))&foo


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