From: Douglas Gregor (gregod_at_[hidden])
Date: 2004-05-07 09:39:24
On Friday 07 May 2004 10:30 am, Dill, John wrote:
> I see your point. But, what if instead of argument_traits being pass by
> value, it by default passes by T const&? What could be done is to have the
> bind_t arguments be passed by const reference, and then use
> reference_wrapper to do type-selection to pass by reference. It still
> supports literals, and passes by T const& when it can, but everything that
> is passed by reference must have a ref( object ). The compiler would fail
> if you try to pass a reference without a reference_wrapper because it by
> default tries to pass a T const&. This wouldn't require the 2^N overloads
> but would require you to do a ref( object ) for everything passed by
> reference. This might also be a workaround for those compilers that don't
> support T& and T const& overloading.
So we'd be trading lvalue support for literal support. In my experience,
lvalues are _much_ more important than literals[*], and we've had these
semantics for a really long time (they'll be part of the C++ Library TR), so
it will take a truly killer argument to change this.
[*] Thinking of my own work, where I use lots of bind expressions, I remember
only once having to name a temporary to get around the T& issue with bind,
but can thinking of at least 4 places where I pass lvalues through bind.
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk