On Monday, 26 February 2018 at 20:04:14 UTC, aliak wrote:
Guess I could do a pointer and call new when i need to store a value instead. Or maybe it's better to do it like above and store as value type with default value and a boolean at the site. Not sure.

You do not need a separate boolean field. If someone assigns "none" or calls popFront() just assign the pointer to null. When someone queries empty, you check whether the pointer points to null. The default value is easy too: typeof(element).init.

That's the superior design, because it does not need any excess memory for the empty flag.


Reply via email to