Rainer Deyke wrote:
Andrei Alexandrescu wrote:
Apparently a good design is to define Optional!T with a minimum of
member functions (ideally none) and have it use the "alias this" feature
to masquerade as a T. That way Optional!T looks and feels much like a T,
except that it supports a function
bool isNull(T)(Optional!T value);
Am I on the right track?
You need some syntactic way to distinguish the contained value from the
container. Using "alias this" seems messy here. Optional!Optional!T is
both valid and likely to occur.
Interesting. I wonder whether it's better to fold Optional!(Optional!T)
into Optional!T.
Andrei