Opened 8 years ago
Closed 7 years ago
#10445 closed Bugs (fixed)
rvalue assign from boost::optional<const T&> doesn't work
| Reported by: | Owned by: | Fernando Cacciola | |
|---|---|---|---|
| Milestone: | Boost 1.61.0 | Component: | optional |
| Version: | Boost 1.56.0 | Severity: | Regression |
| Keywords: | Cc: |
Description
consider the following code:
#include "boost/optional.hpp"
#include <iostream>
struct a
{
int p;
};
boost::optional<const a&> bar() {
static a b;
b.p = 3;
return b;
}
int main(int, char**)
{
boost::optional<a> baz;
baz = bar(); // uh-oh!
std::cout<<baz->p<<std::endl;
return 0;
}
My expectation is that the line marked "uh-oh" should compile correctly and invoke a's copy constructor to fill in baz's a. What actually happens is that I get a compile error saying that I can't static cast from const a& to a&& inside the move assignment operator for optional.
Change History (2)
comment:1 by , 7 years ago
| Milestone: | To Be Determined → Boost 1.61.0 |
|---|
comment:2 by , 7 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
