enforcing alias this on derived types

JS js.mdnq at gmail.com
Mon Jul 8 01:59:14 PDT 2013


I have an interface that I would like to make sure that any 
classes derived from it will use alias this, else it can 
potentially break code.

interface A(T)
{
     @property T Value();
     @property T Value(T value);
     // need to enforce alias _value this somehow
}

class B(T) : A!T
{
     private T _value;
     @property T Value() { return _value; }
     @property T Value(T value) { return value = _value; }
     alias _value this;
     // B must use alias this so B(T) behaves like type T
}


More information about the Digitalmars-d-learn mailing list