Modify

Ticket #10445 (closed Bugs: fixed)

Opened 3 years ago

Last modified 13 months ago

rvalue assign from boost::optional<const T&> doesn't work

Reported by: russell.mcclellan@… Owned by: fcacciola
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.

Attachments

Change History

comment:1 Changed 13 months ago by anonymous

  • Milestone changed from To Be Determined to Boost 1.61.0

comment:2 Changed 13 months ago by akrzemi1

  • Status changed from new to closed
  • Resolution set to fixed
View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.