Getting NotNull Right

"Nordlöw" per.nordlow at gmail.com
Wed Feb 5 13:58:07 PST 2014


On Wednesday, 5 February 2014 at 21:32:36 UTC, Adam D. Ruppe 
wrote:
> The alias this could be changed to allow conversion to the base 
> class one step at a time. I'm not happy with it since it'd 
> essentially do a big chain down to Object and it also ignores 
> interfaces, but it's a start:
>
>     static if(is(T == class) && !is(T == Object))
>     @property NotNull!(BaseClassesTuple!T[0]) _valueHelper() 
> inout
>     {
>         assert(_value !is null); // sanity check of invariant
>         return assumeNotNull(cast(BaseClassesTuple!T[0]) 
> _value);
>     }
>     else
>     @property inout(T) _valueHelper() inout
>     {
>         assert(_value !is null); // sanity check of invariant
>         return _value;
>     }
>
>
> (Previously, it just had the second _valueHelper)

Members of a derived class T become inaccessible in NotNull!T 
with this approach. Do you have any clue to why?


More information about the Digitalmars-d-learn mailing list