Many things are not checked for:
--------------------------
struct NotNull(T) {
T p;
alias p this;
this(T p) {
assert(p != null, "pointer is null");
this.p = p;
}
@disable this();
NotNull opAssign(T p) {
assert(p != null, "assigning null to NotNull");
this.p = p;
return this;
}
}
struct S {
NotNull!(int *) m;
// should fail: an explicit constructor must be required for S
}
void main() {
int i;
NotNull!(int*) n = &i;
*n = 3;
assert(i == 3);
n = &i;
n += 1;
NotNull!(int*)[3] a; // should fail
auto b = new NotNull!(int*)[3]; // should fail
S s = S(); // should fail
}