
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])' Kobi. On 4/26/06, Sebastian Redl <sebastian.redl@getdesigned.at> wrote:
Kobi Cohen-Arazi wrote:
std::vector<Foo> array; // say it is already populated std::vector<std::string> tr; // the transformed instead using my handcrafted for loop, I would like to transform the std::list<Foo>::iterator endIter=array.end (); for (std::list<Foo>::iterator iter=array.begin(); iter!=endIter ;++iter) { noExtResults.push_back (iter.get().replace (0,5, "")); }
I know it should be something like: std::transform (array.begin(), array.end (), std::back_inserter(tr), bind(&Foo::get, _1));
So here I'm stuck. The bind function will know to extract the string using get. But how to I get that string and do something like: bind(&std::string::replace (???))
I'd use straight Boost.Bind, not Lambda. But the syntax is the same:
std::transform(array.begin(), array.end(), std::back_inserter(tr), bind(&std::string::replace, bind(&Foo::get, _1), 0, 5, ""));
Or you could use one of the special iterators from Boost.Iterator instead of the nested bind.
Sebastian Redl _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users