Boost logo

Boost Users :

Subject: Re: [Boost-users] [lambda & range] bind for transformed - how to do it.
From: Sam Fisher (infest21h_at_[hidden])
Date: 2011-11-29 13:45:50


On 29.11.2011 17:09, Robert Jones wrote:
> 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.
Visual Studio 2010 SP1 (with boost from trunk) compiles this code. I
suppose 1.48 will be ok too.
BTW, why using bind or even lambda? There is a more simpler way:

#include <boost/range/iterator_range_core.hpp>
#include <boost/range/adaptor/map.hpp>

std::vector<int> ages(const std::map<std::string, int>& people)
{
     using boost::adaptors::map_values;
     return boost::copy_range<std::vector<int> >(people | map_values);
}


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