libzypp
10.5.0
|
An unary functor forwarding to some other _Functor &
.
More...
Classes | |
struct | FunctorRef0 |
struct | FunctorRef1 |
struct | FunctorRef2 |
struct | nil |
An unary functor forwarding to some other _Functor &
.
Most algorithms take functor arguments by value. That's inconvenient if the functor wants to collect and return data. Creating and passing a FunctorRef to the algorithm, may help you out of this.
// Counts invokations of operator(). template<class _Tp> struct Counter : public std::unary_function<_Tp, void> { void operator()( _Tp ) { ++_value; } Counter() : _value( 0 ) {} unsigned _value; }; std::set<SomeType> c; Counter<SomeType> counter; // Invokations of FunctorRef are forwarded to counter: std::for_each( c.begin, c.end(), // currently you must specify the // operator() signature: functorRef<void,SomeType>(counter) );
_Functor::operator()
. This is currently not automated, so you must specify the operator() signature as template arguments.