6 ms·
::value() method can both return a reference (bare use) and give up the ownership of the wrapped value (used with std::move). You just have to state your intent
by exitb 4y ago
::value() method can both return a reference (bare use) and give up the ownership of the wrapped value (used with std::move). You just have to state your intention correctly. It's not a problem with std::optional specifically, it's just the default C++ behavior. The entire thing works much better in Rust, where move is the default op and copies need to be explicit.