classes by value
Jonathan Marler
johnnymarler at gmail.com
Thu Dec 14 16:45:36 UTC 2017
On Thursday, 14 December 2017 at 16:40:33 UTC, Petar Kirov
[ZombineDev] wrote:
> I think what Dgame meant was:
> https://dlang.org/phobos-prerelease/std_typecons#scoped. For
> the built-in scoped classes, the keyword is 'scope', not
> 'scoped': https://dlang.org/spec/class.html#auto.
>
> So you can have both:
>
> ```
> scope foo = new Foo();
> ```
>
> and:
> ```
> auto foo = scoped!Foo();
> ```
>
> and finally:
> ```
> scope foo = scoped!Foo();
> ```
I completely forgot about the "scoped" template. Yes it appears
to be almost exactly the same, the implementation is very similar
to the code I came up with (with some of the robust "details"
filled in).
More information about the Digitalmars-d
mailing list