rvalue references
via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jun 3 03:11:43 PDT 2015
On Wednesday, 3 June 2015 at 09:53:36 UTC, Namespace wrote:
>> This code needs to be disallowed under DIP25 (or whatever the
>> final DIP will be), of course.
>
> But should work with return ref instead.
It can even be allowed with an extension to DIP25:
struct Sprite {
private Texture* _tex;
this(ref Texture tex return(this)) {
_tex = &tex;
}
}
`return(param)` (or e.g. `out(param)`) means that the reference
can escape through `param`.
The method can't accept an rvalue ref then, of course.
More information about the Digitalmars-d
mailing list