Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-10-16 15:14:17

Herve Bronnimann wrote:

> However, I fail to see the shortcoming in the following approach: add
> 2*N (not 2^N) overloads, one set of N where all arguments are taken
> as &, and another set of N where all the arguments are taken as
> const&. If any invocation argument is a non-const lvalue, then all
> arguments will be taken as & (first set of overloads) since this is
> the only one that will match. And if all arguments can be passed to
> a const&, then the second set of overloads will provide a better
> match than the first, hence no ambiguity.
> Such an extension would allow boost.bind to forward non-const
> rvalues, in the case where none of the arguments is a non-const
> lvalue. So the example showing the limitation of the current
> solution #1 in the document cited above will then work. You still
> will not be able to forward a mix of non-const lvalues and rvalues,
> but it may not happen very frequently (most return arguments I use in
> my code are passed by address, in C style, and an address can be
> matched to a "T* const&"). Also, the cost is not high (what's an
> extra 9 overloads, when you already have 9 :-)

18, not 9. Good idea (we already had the one- and two-argument cases covered
since 2^K is small, but not the rest). Added to CVS HEAD.

Boost list run by bdawes at, gregod at, cpdaniel at, john at