Boost C++ Libraries: Ticket #10445: rvalue assign from boost::optional<const T&> doesn't work https://svn.boost.org/trac10/ticket/10445 <p> consider the following code: </p> <pre class="wiki">#include "boost/optional.hpp" #include &lt;iostream&gt; struct a { int p; }; boost::optional&lt;const a&amp;&gt; bar() { static a b; b.p = 3; return b; } int main(int, char**) { boost::optional&lt;a&gt; baz; baz = bar(); // uh-oh! std::cout&lt;&lt;baz-&gt;p&lt;&lt;std::endl; return 0; } </pre><p> 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&amp; to a&amp;&amp; inside the move assignment operator for optional. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10445 Trac 1.4.3 anonymous Sun, 06 Mar 2016 18:16:09 GMT milestone changed https://svn.boost.org/trac10/ticket/10445#comment:1 https://svn.boost.org/trac10/ticket/10445#comment:1 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.61.0</span> </li> </ul> Ticket akrzemi1 Sun, 06 Mar 2016 18:16:58 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/10445#comment:2 https://svn.boost.org/trac10/ticket/10445#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket