
Thorsten Ottosen:
Doug Gregor skrev:
On Oct 30, 2007, at 6:22 PM, Thorsten Ottosen wrote:
Is there any good reason that boost::reference_wrapper() does not provide a forwarding operator()(), so that we may use it to pass function objects by reference to algorithms?
The only reason is laziness. I hacked up a partial implementation in the sandbox, but I never finished it.
Are you using the preprocessor to generate the overloads?
One could probably manually provide up to four arguments ... I assume this is more than enough, since the main use-case would be when passing a function object to an algorithm, in which case the mojaority of cases would be 1 or 2 arguments.
reference_wrapper::operator() needs result_of, and result_of would likely introduce a dependency into Boost.Bind on the PP library, the MPL, type traits, and everything underneath. The change may be worth it even at this cost, but it's not a no-brainer. It might be nicer if we could devise a way to deliver this functionality in a cost-free manner though, perhaps only in tr1::reference_wrapper?