Any way to move in @disabled this(this) type in to a wrapping template?

aliak something at something.com
Thu Jul 25 19:35:36 UTC 2019


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);
}


More information about the Digitalmars-d-learn mailing list