I really must research how std::optional is implemented: My fear is it could be inefficient and I am overusing it for expressive API.
I really must research how std::optional is implemented: My fear is it could be inefficient and I am overusing it for expressive API.
@taschenorakel It's as simple as it can be: an aggregate of a boolean plus the space necessary to place the optional value into.
By specializing optional for your own types you may get away without the boolean. That is possible if your value type doesn't occupy *all* value representations (2 ^ sizeof type) that sizeof type bytes provide.
@DanielaKEngert Oh, specializing std::optional, that's an adorable idea!
I am thinking about enumerations, and avoiding, or at least handling this annoying "Invalid" member.
am thinking about all these Qt types with an ::isNull() method, that's to obscure to be used as proper API.