In this code (fabricated) sequence, ages_by_bind compiles, but
ages_by_lambda
does not.
I believe this is because the lambda version does not publish result_type
to its
resultant functors, since the increased generality of lambda makes this
difficult
or impossible to do.
Is there any way I can get round this, as it currently makes the
lambda/transformed
combination completely unusable AFAICS.
Thx,
- Rob.
#include <map>
#include <vector>
#include <string>
#include
#include
#include
#include
#include
#include
std::vector<int> ages_by_bind( const std::map & people )
{
using boost::adaptors::transformed;
std::vector<int> result;
boost::range::push_back( result, people | transformed( bind( &
std::map::value_type::second, _1 ) ) );
return result;
}
std::vector<int> ages_by_lambda( const std::map & people )
{
using boost::adaptors::transformed;
namespace ll = boost::lambda;
std::vector<int> result;
boost::range::push_back( result, people | transformed( ll::bind( &
std::map::value_type::second, ll::_1 ) ) );
return result;
}