rvalue references

Manu turkeyman at gmail.com
Tue Apr 23 21:41:33 PDT 2013


On 24 April 2013 14:07, deadalnix <deadalnix at gmail.com> wrote:

> On Wednesday, 24 April 2013 at 03:33:07 UTC, Manu wrote:
>
>> On 24 April 2013 04:44, Walter Bright <newshound2 at digitalmars.com> wrote:
>>
>>  On 4/23/2013 8:33 AM, Manu wrote:
>>>
>>>  "The r-value being passed is assigned to a stack allocated temporary,
>>>> which has
>>>> a lifetime that is identical to any other local variable, ie, the
>>>> lifetime of
>>>> the function in which it appears."
>>>> There, I defined it.
>>>>
>>>>
>>> Locals have a lifetime that is terminated by the closing } of the scope
>>> they appear in. There can be many such scopes in a function.
>>>
>>> There's also the issue of:
>>>
>>>   a || b || c
>>>
>>> If b creates a temporary, it's life ends at the end of the expression or
>>> statement - it's complicated.
>>>
>>>
>> Is it actually complicated?
>> Enclosing scope seems fine too. Can you suggest a case where it could
>> escalate to an outer scope via a scope-ref argument?
>> So let's say then, that lifetime should be identical to a local declared
>> in
>> the same location. No change of any rules is required, it will work as
>> expected.
>>
>
> The issue is that in this case for instance, the temporary is
> conditionally created. Then cannot bind to the enclosing scope.
>

Conditionally created, in the event you pass an rvalue or not? What about
binding?
I don't know what you're saying.

As temporaries can now be created all over the place, it is mandatory to
> define them in a much more specific way than it is done right now.


...I don't follow. There's absolutely nothing special about an implicitly
created temp vs an explicit one.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130424/59957caa/attachment-0001.html>


More information about the Digitalmars-d mailing list