The liabilities of binding rvalues to ref

Jonathan M Davis jmdavisProg at gmx.com
Thu May 9 12:21:19 PDT 2013


On Thursday, May 09, 2013 09:00:43 Steven Schveighoffer wrote:
> On Thu, 09 May 2013 04:20:02 -0400, Manu <turkeyman at gmail.com> wrote:
> > Ah yes, right, C++ fix() would need to be 'const ref&', but we decide in
> > D
> > that 'ref const()' is too restrictive.
> 
> I have no problem with ref const accepting rvalues. As I understand it,
> Andrei's objection (and this may be wrong/incomplete) is that then there
> is no way to say you accept only lvalues as const ref and rvalues via
> non-ref (for performance reasons). But I think there is no technical
> reason preventing that with D.

Given how restrictive const is in D, I think that it would be a mistake to 
make it so that the way to make a ref accept rvalues is by using const.

- Jonathan M Davis


More information about the Digitalmars-d mailing list