DIP69 - Implement scope for escape proof references

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 4 13:24:54 PST 2014


On 12/4/14 3:41 PM, Walter Bright wrote:
> On 12/4/2014 4:03 AM, Martin Nowak wrote:
>> Will it be possible to deduce, that the lifetime of that scoped value
>> is tied to
>> the smart pointer?
>
>    struct RefCounted(T)
>    {
>      T t;
>      scope ref T borrow() { return t; }
>      alias this t;
>    }
>
> This enables RefCounted!T to be implicitly converted to a T, but with a
> scoped result. This is a critical feature, one I spent a lot of time
> thinking about, and hope it's right :-)

Hm... did you mean `alias this borrow`?

-Steve




More information about the Digitalmars-d mailing list