
I use this wrapper: #define RETURNS(...) -> decltype(__VA_ARGS__) { return (__VA_ARGS__); } template<class Fun> struct function_object { boost::optional<Fun> f; function_object() {} function_object(Fun f): f(f) {} function_object(const function_object & rhs) : f(rhs.f) {} // Assignment operator is just a copy construction, which does not provide // the strong exception guarantee. function_object& operator=(const function_object& rhs) { if (this != &rhs) { this->~function_object(); new (this) function_object(rhs); } return *this; } template<class F> struct result {}; template<class F, class T> struct result<F(T)> { typedef decltype(std::declval<Fun>()(std::declval<T>())) type; }; template<class T> auto operator()(T && x) const RETURNS((*f)(std::forward<T>(x))) template<class T> auto operator()(T && x) RETURNS((*f)(std::forward<T>(x))) }; template<class F> function_object<F> make_function_object(F f) { return function_object<F>(f); } Then you can create the transform iterator like this: boost::make_transform_iterator(my_itertor, make_function_object([](int& i) { return i + 1; })); ----- Original Message -----
From: MM <finjulhich@gmail.com> To: Boost-users@lists.boost.org Cc: Sent: Friday, September 21, 2012 6:37 PM Subject: [Boost-users] transform_iterator and c++11 lambda expression
hello it would be great to be pass
transform_iterator( my_iterator, []( reference ) { return /// something } );
directly to STL algorithms.
Currently, one needs to define separately the unarfy function as far as i could see
MM _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users