Lars Gullik Bjønnes wrote: > This patch is really only what is left of the old iterator patch > series. And basically all the stuff that was dependant upon boost > 1.31.0. > > I am not sure about the functor stuff herein, but the iterator > adaptor usage seems nice to me. Also the boost::next change is IMHO > good. (the deref is horrible, and I'll never apply that one...)
> So if you have comments to this patch likes/dislikes I'd be happy to > receive them... - vector<string> nvec; - std::copy(bstore.begin(), bstore.end(), - lyx::back_inserter_fun(nvec, &Buffer::fileName)); + vector<string> nvec( + make_transform_iterator(bstore.begin(), + bind(&Buffer::fileName, _1)), + make_transform_iterator(bstore.end(), + bind(&Buffer::fileName, _1)) + ); It's not exactly readable is it ;-) I've been using Boost.Spirit a lot at work recently and so have become quite comfortable with Spirit's phoenix library (a better lambda?) Try this for size: #include <boost/spirit/phoenix.hpp> #include <iostream> #include <string> #include <vector> struct Buffer { Buffer(std::string const & name) : name_(name) {} std::string const & name() const { return name_; } private: std::string name_; }; char const * const names[] = { "angus", "ben", "chris", "dave" }; int const size_names = sizeof(names) / sizeof(names[0]); int main () { using phoenix::arg1; using phoenix::bind; using phoenix::var; std::vector<Buffer> bstore(names, names + size_names); std::vector<std::string> nvec(bstore.size()); std::vector<std::string>::iterator nvit = nvec.begin(); std::for_each(bstore.begin(), bstore.end(), (*var(nvit) = bind(&Buffer::name)(arg1), var(nvit)++)); std::for_each(nvec.begin(), nvec.end(), std::cout << arg1 << ' '); std::cout << std::endl; } -- Angus