Initialise non-copyable, non-default-constrauctable member struct
Peter Particle
ParticlePeter at gmx.de
Fri Jul 27 12:11:37 UTC 2018
Question is related to this:
https://dlang.org/spec/struct.html#disable_default_construction
struct S {
int x;
@disable this(); // Disables default construction
@disable this(this); // Disable copying
this(int v) { x = v; }
}
struct T {
float y;
S s;
@disable this(); // Disables default construction
@disable this(this); // Disable copying
this(float v) {
y = v;
s = S(cast(int)v); // tried option 1
s.__ctor(cast(int)v); // tried option 2
}
}
Error: struct `S` is not copyable because it is annotated with
`@disable`
in both cases.
Is there some way around this problem?
More information about the Digitalmars-d-learn
mailing list