[Boost-bugs] [Boost C++ Libraries] #10445: rvalue assign from boost::optional<const T&> doesn't work

Subject: [Boost-bugs] [Boost C++ Libraries] #10445: rvalue assign from boost::optional<const T&> doesn't work
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-09-02 22:51:25


#10445: rvalue assign from boost::optional<const T&> doesn't work
---------------------------------+------------------------
 Reporter: russell.mcclellan@… | Owner: fcacciola
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: optional
  Version: Boost 1.56.0 | Severity: Regression
 Keywords: |
---------------------------------+------------------------
 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.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10445>
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:16 UTC