Possible Duplicate:
Should templated functions take lambda arguments by value or by rvalue reference?
The C++ standard library functions take functor (function pointer or function object) arguments by value, like so:
template <typename F>
void apply(F func)
{
func();
}
...But wouldn't it be better to pass functors by Universal Reference? Like so:
template <typename F>
void apply(F&& func)
{
func();
}
This way you could pass function objects that maintain state, and have access to that (possibly modified) state after the higher-order function has returned.