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
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
From: MM
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
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
You can use the 'regular' function from Akira Takahashi's extensions to the Boost.Range library [1] like so: make_transform_iterator(my_iterator, regular([]( ... ) { ... })); If you are using the 'transformed' range adaptor instead of using transform_iterator directly, it's even nicer: you just use '|+' to pipe the adaptor instead of '|'. That is, R | transformed([](...){...}) becomes R |+ transformed([](...){...}) Regards, Nate [1] http://dl.dropbox.com/u/1682460/git/OvenToBoost/libs/range/doc/html/range_ex...
participants (3)
-
MM
-
Nathan Ridge
-
paul Fultz