Nullable!T

bearophile bearophileHUGS at lycos.com
Tue Jul 6 07:51:17 PDT 2010


Adam Ruppe:
> I figure a Nullable struct would just alias the original type if T t;
> t = null; already compiles. So a nullable pointer, class, or Nullable
> is just a no-op. This would cover your cases 1 and 2 with a simple
> rule.

I don't think that's a good idea, you lose the standard API of Nullable, so it's worse than useless.
Two better solutions are the one chosen by C# (refuse object references as T) or accept them too (and don't add a boolean after the T, using the null reference to store the missing T).

Bye,
bearophile


More information about the Digitalmars-d mailing list