Boost
Libraries
arrow_drop_down
Boost.Optional
M
D
C++ 11 Added in Boost 1.30.0
Categories:   Data

A value-semantic, type-safe wrapper for representing 'optional' (or 'nullable') objects of a given type. An optional object may or may not contain a value of the underlying type.

Commits Per Release10010080806060404020200016000220141000025004010008701.69.01.69.01.70.01.70.01.71.01.71.01.72.01.72.01.73.01.73.01.74.01.74.01.75.01.75.01.76.01.76.01.77.01.77.01.78.01.78.01.79.01.79.01.80.01.80.01.81.01.81.01.82.01.82.01.83.01.83.01.84.01.84.01.85.01.85.01.86.01.86.01.87.01.87.01.88.01.88.0

This Release

Fernando Cacciola
Author
Andrzej Krzemieński
Andrzej Krzemieński
Maintainer

optional

A library for representing optional (nullable) objects in C++.

optional<int> readInt(); // this function may return either an int or a not-an-int

if (optional<int> oi = readInt()) // did I get a real int
  cout << "my int is: " << *oi;   // use my int
else
  cout << "I have no int";

For more information refer to the documentation provided with this library.