Boost logo

Boost Users :

From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2006-04-27 04:07:50


Kobi Cohen-Arazi wrote:

> Hi,
>
> I've tried that, and I got a bunch of errors. I'm using boost::bind
> for that, not boost::lambda.
> Here is the error
>
> The following line:
> std::transform(array.begin(), array.end(), std::back_inserter(tr),
> bind(&std::string::replace, bind(&Foo::get, _1), 0, 5, ""));
>
> generates:
> error: no matching function for call to 'bind(<unknown type>,
> boost::_bi::bind_t<const std::string&, boost::_mfi::cmf0<const
> std::string&, Foo>, boost::_bi::list1<boost::arg<1> > >, int,
> uint32_t&, const char [1])'

Hmmm ... the <unknown type> is suspicious. The problem might be that
&std::string::replace is ambiguous, as it is overloaded. Try this:

std::string & (std::string::*rep)(std::string::size_type,
std::string::size_type, const char *) = &std::string::replace;
std::transform(array.begin(), array.end(), std::back_inserter(tr),
  bind(rep, bind(&Foo::get, _1), 0, 5, ""));

Sebastian Redl


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net