Destructors, const structs, and opEquals

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Dec 4 06:35:20 PST 2010


On 12/4/10 8:29 AM, Jonathan M Davis wrote:
> On Saturday 04 December 2010 06:00:58 Andrei Alexandrescu wrote:
>> On 12/4/10 4:35 AM, Jonathan M Davis wrote:
>>> On Friday 03 December 2010 22:42:06 Don wrote:
>>>> (1) Should temporaries be allowed to be passed as 'const ref'?
>>>
>>> I honestly do not understand why they can't be already. C++ definitely
>>> allows this.
>>
>> C++'s second biggest mistake.
>
> Okay. Why is it a mistake? I've never heard anyone say that this was a mistake
> before. As far as I can tell, it's extremely desirable, and this problem with
> opEquals() is a prime example as to why. What is wrong with allowing temporaries
> to be passed as const ref? What makes it such a big mistake?

It makes it impossible to distinguish an rvalue from an lvalue.

Andrei


More information about the Digitalmars-d mailing list