
Hi, Nathan. This problem is known issue. PStade.Oven Library have solution by regular function. http://p-stade.sourceforge.net/oven/doc/html/oven/utilities.html#oven.utilit... I’ve been doing for now, Oven to Boost.Range porting project. https://github.com/faithandbrave/OvenToBoost Using this library you can write as follow: #include <boost/range/algorithm/min_element.hpp> #include <boost/range/adaptor/filtered.hpp> #include <boost/range/regular.hpp> int main() { int a[] = {1, 2, 3}; auto is_odd = [](int i){ return i % 2 == 1; }; boost::min_element(a | boost::adaptors::filtered(boost::regular(is_odd))); } or, use regular operator(operator|+) version: #include <boost/range/algorithm/min_element.hpp> #include <boost/range/adaptor/regular_extension/filtered.hpp> int main() { int a[] = {1, 2, 3}; auto is_odd = [](int i){ return i % 2 == 1; }; boost::min_element(a |+ boost::adaptors::filtered(is_odd)); } 2011/5/30 Nathan Ridge <zeratul976@hotmail.com>:
Hello,
I get errors related to lambdas not being default-constructible or copy-assignable when using a lambda as a predicate with certain adaptors (e.g. filtered) and certain algorithms (e.g. min_element).
The following code illustrates the problem:
#include <boost/range/algorithm/min_element.hpp> #include <boost/range/adaptor/filtered.hpp> int main() { int a[] = {1, 2, 3}; auto is_odd = [](int i){ return i % 2 == 1; }; boost::min_element(a | boost::adaptors::filtered(is_odd)); }
The errors are shown below.
Is there a workaround for this?
Thanks, Nate.
======================== Akira Takahashi mailto : faithandbrave@gmail.com blog : http://d.hatena.ne.jp/faith_and_brave/