Efficient optional values -- Andrzej Krzemieński

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:

  1. Because my type T has no null state (like -1) that would indicate that I have no proper value.
  2. Because, I need to perform a two-phase initialization (I cannot initialize my T yet, but I already need it alive).
  3. 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.

Comments (0)

There are currently no comments on this entry.