Boost logo

Boost :

Subject: Re: [boost] [range] concept checks break chained range adaptors
From: Sergey Mitsyn (svm_at_[hidden])
Date: 2014-06-15 05:20:58


Hello,

> std::vector<std::string> separated
> std::set<Foo> foos;
>
> boost::copy(separated |
> boost::adaptors::transformed(boost::bind(Foo::fromString, _1))
> |
> boost::adaptors::filtered(boost::bind(&Foo::isValid, _1)),
> std::inserter(foos, foos.end()));
>

boost::copy forwards everything to std::copy with iterators that hold
function objects by value. Iterator concept requires iterators to be
default constructible, but if they hold function objects that have
binded data they cannot be made such.

FWIW one of solutions to this problem is wrapping function object f with
boost::regular(f), available here:

https://github.com/faithandbrave/OvenToBoost

AFAIR it's supposed to be integrated into boost some day, and also there
was some discussion in this list about it.

-- 
------------
Sergey Mitsyn.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk