xxxxxxxxxx
struct W(T) {
T value;
this(U : T)(auto ref inout(U) value) inout {
this.value = value;
}
}
auto defined(T)(auto ref inout(T) value) {
return inout(W!T)(value);
}
auto defined(T)(auto ref const(T) value) {
return W!T(value);
}
auto undefined(T)() {
return W!T();
}
void main() {
auto a = defined("hello");
auto b = undefined!string;
static assert(is(typeof(a) == W!string));
static assert(is(typeof(b) == W!string));
static class C {}
auto c = defined(cast(immutable C)(new C));
auto d = defined!(int*)(null);
}