structs are now lvalues - what is with "auto ref"?

monarch_dodra monarchdodra at gmail.com
Mon Dec 24 11:03:24 PST 2012


On Monday, 24 December 2012 at 18:42:31 UTC, Andrei Alexandrescu 
wrote:
> On 12/24/12 1:05 PM, monarch_dodra wrote:
>> On Monday, 24 December 2012 at 17:37:54 UTC, Andrei 
>> Alexandrescu wrote:
>>> On 12/24/12 12:11 PM, Jonathan M Davis wrote:
>>>> On Monday, December 24, 2012 17:55:23 Minas Mina wrote:
>>>>> On Sunday, 23 December 2012 at 23:59:55 UTC, Jonathan M 
>>>>> Davis
>>>>>
>>>>> wrote:
>>>>>> On Monday, December 24, 2012 00:48:01 Namespace wrote:
>>>>>> but Andrei is dead set against
>>>>>>
>>>>>> - Jonathan M Davis
>>>>>
>>>>> Why?
>>>>
>>>> He's convinced that it's caused problems for C++ and was a 
>>>> major
>>>> mistake. You
>>>> can search the newsgroup for discussions on it. The most 
>>>> recent one
>>>> which
>>>> involved Andrei was in the beta group:
>>>>
>>>> http://forum.dlang.org/post/4F84D6DD.5090405@digitalmars.com
>>>>
>>>> - Jonathan M Davis
>>>
>>> An important smoking gun is C++'s min(), which is allows 
>>> writing
>>> unsafe code without casts.
>>>
>>> const int& haveANiceDay = min(4, 5);
>>>
>>>
>>> Andrei
>>
>> But that example actually works correctly.
>
> No.
>
> Andrei

Hum... Indeed, it takes by ref *and* returns by ref. Passing in 
to out a const ref is *the* smoking gun. Working with D has 
gotten me used to functions that take by value and return by 
value...

Snap. You got me.


More information about the Digitalmars-d-learn mailing list