Struct that destroys its original handle on copy-by-value

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 3 02:01:49 PDT 2015


On Monday, 3 August 2015 at 08:54:32 UTC, Kagamin wrote:
> On Saturday, 1 August 2015 at 11:47:29 UTC, Joseph Rushton 
> Wakeling wrote:
>> Yea, but that's not what I'm trying to achieve.  I know how I 
>> can pass something to `take` so as to e.g. obtain reference 
>> semantics or whatever; what I'm trying to achieve is a range 
>> that _doesn't rely on the user knowing the right way to handle 
>> it_.
>
> Wrapping a reference to a stack-allocated struct is also 
> unsafe, so no way for the user to not know about it.

It is now verified as safe by `return ref`.


More information about the Digitalmars-d-learn mailing list