Ie:
struct S {
@disable this(this);
this(int i) {}
}
struct Container(T) {
T value;
this(T value) {
this.value = value;
}
}
void main() {
auto a = Container!S(S(3)); // can't do this.
}
I can build a custom constructor for Container that makes this
work:
static auto construct(Args...)(auto ref Args args) {
import std.algorithm: move;
auto value = T(args);
auto opt = Container!T.init;
opt.value = move(value);
return move(opt);
}
And then "auto a = Container!T.construct(3);" works.
But is there a way to do it without adding a custom constructor
type?
Cheers,
- Ali