Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Implementation Notes

optional<T> is currently implemented using a custom aligned storage facility built from alignment_of and type_with_alignment (both from Type Traits). It uses a separate boolean flag to indicate the initialization state. Placement new with T's copy constructor and T's destructor are explicitly used to initialize,copy and destroy optional values. As a result, T's default constructor is effectively by-passed, but the exception guarantees are basic. It is planned to replace the current implementation with another with stronger exception safety, such as a future boost::variant.


PrevUpHomeNext