scoped classes
Alex via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Apr 26 23:40:49 PDT 2017
Hi all,
a short question about an example.
having read this:
https://dlang.org/library/std/typecons/scoped.html
There is a struct B defined in the middle of the example, with a
scoped class member.
How to define an array of such members (and to put some items to
it)?
So, I want to have something like
// Use as member variable
struct B
{
typeof(scoped!A())[] a; // note the trailing parentheses
this(int i)
{
// construct member
a.length = 5; // doesn't work, as the default constructor
is disabled.
a ~= scoped!A(i); // doesn't work, as the type is not
copyable
// ???
}
}
More information about the Digitalmars-d-learn
mailing list