"Value class instance" pattern?
Dicebot
public at dicebot.lv
Sun Jul 14 05:28:47 PDT 2013
On Saturday, 13 July 2013 at 12:47:28 UTC, bearophile wrote:
> ...
Hm, actually naive scoped usage seems to work for me:
---------------------------------------
import std.typecons;
class B
{
byte a;
}
class A
{
typeof(scoped!B()) b = void;
this()
{
b = scoped!B();
}
}
---------------------------------------
...with only exception (bug?) - I can't default-construct A on
heap after that. It works as expected if I created A via scoped
or use non-default constructor.
More information about the Digitalmars-d
mailing list