Modify

Opened 3 years ago

Closed 21 months ago

#10445 closed Bugs (fixed)

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

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

Attachments (0)

Change History (2)

comment:1 Changed 21 months ago by anonymous

Milestone: To Be DeterminedBoost 1.61.0

comment:2 Changed 21 months ago by akrzemi1

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Fernando Cacciola.
The resolution will be deleted.

Add Comment


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

 
Note: See TracTickets for help on using tickets.