You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
g++7 setup for c++17
Method of expected class 'constexpr value_type && Expected::value() const &&' does not compile.
In case when You invoke 'value()' method on r-value of 'expected' object the compiler will complain about problem with matching const l-value to r-value, the reason is overloading storage_t::value() method. We have 3 methods value:
1) constexpr value_type const & value() const &
2) value_type & value() &
3) constexpr value_type && value() const &&
In 'expected::value() const &&' we have:
return has_value()
? ( contained.value() ) // contained is a member of expected of type storage_t< T, E >
....
'contained' is l-value and 'expected::value() const &&' is a const method, so the only posible match of overloaded 'storage_t::value()' invoked in 'expected::value() const &&' is (1), which returns value_type const& which cannot be bound to r-value of value_type.
The text was updated successfully, but these errors were encountered:
marcin-icek
changed the title
method constexpr value_type && Expected::value() const && does not compile
method constexpr value_type && expected::value() const && does not compile
Jun 24, 2018
marcin-icek
changed the title
method constexpr value_type && expected::value() const && does not compile
method 'constexpr value_type && expected::value() const &&' does not compile
Jun 24, 2018
g++7 setup for c++17
Method of expected class 'constexpr value_type && Expected::value() const &&' does not compile.
In case when You invoke 'value()' method on r-value of 'expected' object the compiler will complain about problem with matching const l-value to r-value, the reason is overloading storage_t::value() method. We have 3 methods value:
1) constexpr value_type const & value() const &
2) value_type & value() &
3) constexpr value_type && value() const &&
In 'expected::value() const &&' we have:
return has_value()
? ( contained.value() ) // contained is a member of expected of type storage_t< T, E >
....
'contained' is l-value and 'expected::value() const &&' is a const method, so the only posible match of overloaded 'storage_t::value()' invoked in 'expected::value() const &&' is (1), which returns value_type const& which cannot be bound to r-value of value_type.
The text was updated successfully, but these errors were encountered: