Binding rvalues to ref [WAS: I close BIP27. I won't be pursuing BIPs anymore]

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 19 09:48:54 PDT 2016


On 10/19/2016 11:38 AM, Jonathan M Davis via Digitalmars-d wrote:
> On Wednesday, October 19, 2016 07:55:19 Andrei Alexandrescu via Digitalmars-d
> wrote:
>> This was C++'s big un' that led to many complications. If the overload
>> weren't ambiguous, a large part of rvalue references would have been
>> unneeded. (Universal references would still have been necessary for
>> perfect forwarding, but that's not the bulk.)
>>
>> In order to avoid such issues, we steered clear off binding rvalues to
>> ref parameters in the D language. As I mentioned to Ethan, I do agree a
>> careful definition may be able to avoid the fallout that happened in
>> C++. It would be a fair amount of work.
>
> The other big problem is that D's const is so much more restrictive than
> C++'s that even if const ref accepted rvalues, a large portion of the time,
> it would be too restrictive to be useful.

That's why if we allow binding rvalues to references, we'd allow it 
regardless of const. -- Andrei




More information about the Digitalmars-d mailing list