
Hi Sebastian, Hmmm...... I think I know what the problem is ... Foo::get is const struct Foo{ std::string get() const { ... } }; So it is not a good candidate to use in string::replace. I wonder how I can work around it, since I want to transform a _copy_ of that. Is there a way to create a copy on the fly? something like: ...bind(rep, std::string(bind(&Foo::get, _1)), 0, 5, "")); Thanks again for your insights. Kobi. On 4/27/06, Sebastian Redl <sebastian.redl@getdesigned.at> wrote:
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 mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users