Is there a way to disable copying of an alias this'd member? - trying to make a NotNull type
aliak
something at something.com
Fri May 24 10:16:50 UTC 2019
Basically, I want this to fail:
auto notNull(T, Args...)(Args args) {
return NotNull!T(new T(args));
}
struct NotNull(T) {
private T _value;
@property ref inout(T) value() inout { return this._value; }
alias value this;
//disable opAssign to null as well
}
class C {}
void func(ref C t) {
t = null;
}
auto a = notNull!C;
func(a); // i want a compile error here
Any ideas that don't involve disabling copying or making the
property non-ref?
Full example here: https://run.dlang.io/is/ubOwkd
Thanks!
More information about the Digitalmars-d-learn
mailing list