As shown by this page, the rvalue ref-qualified version of std::optional<T>::value_or is not marked constexpr:
template< class U >
constexpr T value_or( U&& default_value ) const&;
template< class U >
T value_or( U&& default_value ) &&;
What's the reasoning behind this? Is it because the move of the value can modify the optional object?
UPDATE: Oh, I think I actually understand now. An rvalue constexpr optional object will match the const & version anyway.
Aucun commentaire:
Enregistrer un commentaire