Hi all,
std::reference_wrapper includes an overload of operator()[1] which allows a
wrapped function object to be called without needing to first unwrap:
#include
#include <functional>
#include <iostream>
int main()
{
auto f = [](int i) { std::cout << i * 2 << std::endl; };
std::ref(f)(5);//change this to boost::ref and it will not compile.
}
I think it would be valuable to update boost::ref to match the standard
version. On compilers which support variadic templates and rvalue
references the code is obvious. Those which support one or neither could
still have overloads for some number of arguments.
This would be handy in a few places, notably
boost::gil::for_each_pixel[2]. I know that boost::bind + reference wrapper
could be used instead (boost::bind(boost::ref(f), 5)). Given that
implementing operator() is relatively simple, and that the standard object
based on boost::reference_wrapper has it (rather than requiring std::bind),
I'd argue that this change is desirable.
Thanks,
Nate
[1]
http://en.cppreference.com/w/cpp/utility/functional/reference_wrapper/operat...
[2]http://comments.gmane.org/gmane.comp.lang.c%2B%2B.isocpp.general/513