Andrzej goes into some details of optional values in his recent blog post.
Efficient optional values
by Andrzej Krzemieński
From the article:
What do you use Boost.Optional for? In my experience, the answer was typically one of the following:
- Because my type T has no null state (like -1) that would indicate that I have no proper value.
- Because, I need to perform a two-phase initialization (I cannot initialize my T yet, but I already need it alive).
- Because I need an interface that would indicate to the type system that my value may not be there and that its potential absence should be checked by the users.
In this post we will focus exclusively on the third motivation.
Add a Comment
Comments are closed.