https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77288

--- Comment #4 from dawid_jurek at vp dot pl ---
After applying my patch code snippet you provided compile, run and works as
expected. To be more precise I'm talking about such snippet:

std::experimental::optional<std::string> os;
os = "meow";
assert(bool(os) && *os == "meow");

You are right that operator=(_Up&& __u) won't be choose here as overload
candidate. 
Anyway there is converting constructor:

template <typename _Up, .. >
constexpr optional(_Up&& __t) 

and generated move constructor:

optional<_Tp>::optional(optional<_Tp>::optional<_Tp>&& )

Let's see what happen when flow achieve expression: os = "meow" 

1. Call optional::optional<_Tp>::optional(_Up&& __t) where _Tp = std::string,
_Up = char const (&) [13]  
   for r-value "meow" and create temporary optional<std::string> containing
"meow".
2. Call generated
optional::optional<_Tp>::optional(optional<_Tp>::optional<_Tp>&& ) where _Tp =
std::string
   and just transfer ownership from temporary optional to os.
3. Now os is engaged, os contains "meow" and assertion is happy. 

Regards,
Dawid

Reply via email to