...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::optional
is specialized for reference
parameters. This addresses a couple of issues:
sizeof
of optional
reference is that of a pointer,
<type_traits>
.
boost::none
again. Now it is a const object with internal linkage (as any other tag).
This fixes Trac
#11203.
emplace()
,
and therewith removed the dependency on <boost/utility/in_place_factory.hpp>
.
boost::none_t
is no longer convertible from
literal 0
. This avoids a bug
where optional<rational<int>> oi = 0;
would
initialize an optional object with no contained value.
optional
without header optional_io.hpp
by using safe-bool idiom. This addresses Trac
#10825.
BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES
.
This can be used to work around Trac
#10399.
optional<U>
to optional<T>
when U
is not assignable or convertible to T
(Trac #11087).
optional<T&>
(Trac
#10839).
<string>
to fix C++03 compile error on logic_error("...")
".
optional<T>
works with moveable but non-copyable
T
's,
swap
(now uses
move operations),
emplace()
. This is the last of the requests from
Trac #1841,
optional
is moveable, including
conditional noexcept
specifications,
which make it move_if_noexcept
-friendly,
operator<<(ostream&, optional
const&)
to prevent inadvertent incorrect serialization of optional objects,
reset()
from examples (Trac
#9005),
boost::none
does not require that T
be EqualityComparable,
value()
, value_or()
, value_or_eval()
,