On Thursday, 13 December 2018 at 12:08:22 UTC, Boris-Barboris wrote:
On Thursday, 13 December 2018 at 09:51:42 UTC, aliak wrote:
[...]


You can just move in container constructor:


struct S {
    @disable this(this);
    this(int i) {}
}

struct Container(T) {
    T value;
    this(T value) {
        import std.algorithm: move;
        this.value = value.move;
    }
}

void main() {
    auto a = Container!S(S(3));
}

Ah. Is there any case where you would not want to do that when you have a T value as parameter?

And, what if it's "this()(auto ref T value)"? Then moving could be dangerous if the parameter was passed as a ref. Or maybe it just wouldn't compile?

Reply via email to