Subject: [Boost-bugs] [Boost C++ Libraries] #12652: boost::optional<DefaultConstructable>::operator= chooses wrong overload for {}
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-12-07 01:03:10
#12652: boost::optional<DefaultConstructable>::operator= chooses wrong overload for
{}
------------------------------+-----------------------
Reporter: mathias@⦠| Owner: fcacciola
Type: Bugs | Status: new
Milestone: To Be Determined | Component: optional
Version: Boost 1.61.0 | Severity: Problem
Keywords: |
------------------------------+-----------------------
{{{
boost::optional<int> op = 5; // creates engaged optional
op = {}; // currently does op = 0;
}}}
For most types operator={} assigns from a value-constructed value of that
type. That is the behavior of std::experimental::optional but not
boost::optional<T>. It chooses the T&& overload. I think the standard
avoids it by having the assign-from-T operator= be templated on U instead,
which doesn't match {}.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/12652> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC