Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

method 'constexpr value_type && expected::value() const &&' does not compile #15

Closed
marcin-icek opened this issue Jun 24, 2018 · 0 comments

Comments

@marcin-icek
Copy link

marcin-icek commented 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.

@marcin-icek 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 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
martinmoene added a commit that referenced this issue Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants