Boost
boost
arrow_drop_down
Join
Boost.Optional
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.

Maintainers & Contributors

akumta
Aleksey Gurtovoy
Alexander Grund
Alexander Grund
Andrey Semashev
Andrey Semashev
Anthony
Anthony Leedom
Beman Dawes
Benjamin Roland Buch
Casey Carter
Daniel J. Hofmann
Daniel James
Daniel Seither
Dave Abrahams
Douglas Gregor
drivehappy
Edward Diener
Fernando Cacciola
Fredrik Blomqvist
Gennadiy Rozental
Gennaro Prota
gieseanw
Giovanni Mascellani
glywk
Hartmut Kaiser
Jens Maurer
Jeremiah Willcock
John Maddock
Josh Soref
Jürgen Hunold
Kazutoshi SATODA
Kohei Takahashi
Marcel Raad
Markus Schöpflin
Marshall Clow
Matias Capeletto
Matt
Michael A. Jackson
Mike Dev
Moritz Baumann
Niels Dekker
Nikita Kniazev
nobody
Olaf van der Spek
petamas
Peter Dimov
Peter Dimov
Peter Klotz
Ralf W. Grosse-Kunstleve
Rene Rivera
Robert Leahy
sdarwin
Sebastian Redl
Siddhant Saraf
Stefan Seefeld
Stephen Kelly
Steven Watanabe
Tolga HOŞGÖR
Tosiekdev
Troy D. Straszheim
typenameTea
Vicente J. Botet Escriba
Vinnie Falco
Vladimir Prus

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.