Can the last line, labelled NOT Ok, be made to work? I think the lambda does
not publish its result as a bind does, so I suspect it's hopeless. Any thoughts?
Thx, Rob.
#include <boost/range/adaptor/transformed.hpp>
#include <boost/range/algorithm_ext/push_back.hpp>
#include <boost/bind.hpp>
#include <vector>
#include <algorithm>
struct S { int i; };
void f( std::vector<int> & out, std::vector<S> & in )
{
using boost::adaptors::transformed;
// Ok
std::transform( in.begin( ), in.end( ), std::back_inserter( out ), bind( & S::i, _1 ) );
// Ok
boost::range::push_back( out, in | transformed( bind( & S::i, _1 ) ) );
// Ok
std::transform( in.begin( ), in.end( ), std::back_inserter( out ), []( S & s ) { return s.i; } );
// NOT Ok
boost::range::push_back( out, in | transformed( []( S & s ) { return s.i; } ) );
}