|
Boost Users : |
From: Kobi Cohen-Arazi (kobi.cohenarazi_at_[hidden])
Date: 2006-04-26 18:36:54
Hi,
Would like to do the following with boost::lambda::bind
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <algorithm>
using namespace boost::lambda;
struct Foo{
std::string get(){ ... }
};
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 (???))
Thanks in advance for your kind help,
Kobi.
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