Basically, can template W be made to handle an S that can't be copied?

import std;

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

struct W(T) {
    T value;
    this(T value) {
        this.value = value;
    }
}

auto wrap(T)(T value) {
    return W!T(value);
}

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

I tried doing something like:

W!T construct(Args...)(auto ref Args args) {
  import std.algorithm: move;
  auto value = T(args);
  W!T w;
  w.value = move(value);
  return move(opt);
}

Reply via email to