![]() |
Home | Libraries | People | FAQ | More |
For compilers with full C++11 support (including "unrestricted unions"
and ref-qualifiers) changed the implementation from aligned storage to
union storage. This enables the gradual constexpr
support:
const-qualified
accessors become usable in compile-time contexts (are core
constant expressions) for types satisfying certain constraints.
optional
from not having a value to having a value), for co-operating types.
swap.
Hardly anyone knows about this mechanism and it was never documented.
std::optional:
o = {}
for putting optional objects to no-value state.
o.value_or({}), which uses a default-constructed
T.
o =
u, where o is of type optional<T> and u
is of type U convertible
to T, does not create
a temporary T.
optional<T>& to optional<T&>. This addresses issue
#142.
none_t is now std::equality_comparable, which means that
none_t and optional<T>
model concept std::equality_comparable_with (for std::equality_comparable Ts),
which means that you can std::ranges::find(rng, boost::none) for a range of optional objects.
Warning. In the future releases we intend
to introduce the range interface in optional,
so that std::ranges::range<optional<T>>
will be true. This may affect
the overload resolution in programs that make decisions based on predicates
such as std::ranges::range. For instance, the following code
will start behaving differently:
template <typename T> void serialize(T const& v) { if constexpr (std::ranges::range<T>) serialize_as_range(v); else if constexpr (custom::is_optional_like<T>) serialize_as_optional(v); else serialize_as_value(v); }
optional,
so that std::ranges::range<optional<T>>
will be true. This may affect
the overload resolution in programs that make decisions based on predicates
such as std::ranges::range.
in_place_init and
in_place_init_if become
inline constexpr
and therewith leave smaller footprint in the executable. This addresses
issue #103.
T,
but it avoids undefined behavior when optional<T> is copied. This fixes issue
#108.
-Wmaybe-uninitialized
warnings in GCC 12. Thanks to Christian Mazakas for the fix.
std::hash<boost::optional<T>>.
This fixes issue
#55. You may get compiler errors when your program provides specializations
for std::hash<boost::optional<T>>.
If this happens, define macro BOOST_OPTIONAL_CONFIG_DO_NOT_SPECIALIZE_STD_HASH
to suppress the specializations of std::hash
in this library.
boost::none is constexpr-declared.
boost::none is now declared as an inline variable
(on compilers that support it): there is only one instance of boost::none across all translation units.
optional<T> for trivial Ts.
Thanks to Robert Leahy for the fix. For details see pr
#78.
-Wweak-vtables.
has_value() for compatibility with std::optional (issue
#52).
map() for transforming optional<T> into optional<U> using a function of type T -> U.
flat_map() for transforming optional<T> into optional<U> using a function of type T -> optional<U>.
-Wzero-as-null-pointer-constant warnings.
optional
is now trivially-copyable for scalar Ts.
This uses a different storage (just T
rather than aligned_storage).
We require the compiler to support defaulted functions.
operator== to get rid of the -Wmaybe-uninitialized false-positive warning
from GCC.
emplace()
functions: they initialize the contained value by perfect-forwarding the
obtained arguments. One constructor always initializes the contained value,
the other based on a boolean condition.
o =
{} now correctly un-initializes
optional, just like in std::optional.
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(),