Opened 6 years ago
Closed 6 years ago
#12652 closed Bugs (fixed)
boost::optional<DefaultConstructable>::operator= chooses wrong overload for {}
Reported by: | Owned by: | Fernando Cacciola | |
---|---|---|---|
Milestone: | Boost 1.63.0 | Component: | optional |
Version: | Boost 1.63.0 | Severity: | Problem |
Keywords: | Cc: |
Description
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 {}.
Attachments (1)
Change History (2)
by , 6 years ago
comment:1 by , 6 years ago
Milestone: | To Be Determined → Boost 1.63.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Version: | Boost 1.61.0 → Boost 1.63.0 |
Already fixed in 1.63
Note:
See TracTickets
for help on using tickets.
Shows the issue. (Compiled with g++6.2 with no extra args)