
Douglas Gregor <gregod@cs.rpi.edu> writes:
On Thursday 06 May 2004 05:32 pm, Dill, John wrote:
I believe that this can be done, but doesn't justify whether it should be done. There are several issues that I see at the moment.
A. Changes the semantics of everyone's bind and mem_fn, no biggy there ;-). B. Pass by value is silent, not sure how many copies of the argument will be generated if pass-by-value.
But at the same time there is an advantage.
a. You can use literals in calling your bind functions.
What do you all think?
I don't like the change.
Ideally, bind(f, _1, _2, _3)(x, y, z) would be exactly equivalent to f(x, y, z). The current bind() implementation gives us nearly this equivalence because it passes by reference, except that we get a failure at compile time if one tries to pass a literal.
Or any rvalue for that matter.
Going to passing by value would take us further from that ideal equivalence.
I agree. IMO the best answer for now is to generate the 2^N overloads of operator() for some user-selectable N. Unary and binary functions are so common that IMO usually N==2 will do it. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com