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

Rvalue qualified functions reuse lvalue versions of corresponding functions. #21

Merged
merged 1 commit into from
Aug 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions include/nonstd/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,12 @@ union storage_t

value_type const && value() const optional_refref_qual
{
return * value_ptr();
return std::move( value() );
}

value_type && value() optional_refref_qual
{
return * value_ptr();
return std::move( value() );
}

#endif
Expand Down Expand Up @@ -829,14 +829,12 @@ class optional

optional_constexpr value_type const && operator *() const optional_refref_qual
{
return assert( has_value() ),
std::move( contained.value() );
return std::move( **this );
}

optional_constexpr14 value_type && operator *() optional_refref_qual
{
return assert( has_value() ),
std::move( contained.value() );
return std::move( **this );
}

#endif
Expand Down Expand Up @@ -878,18 +876,12 @@ class optional

optional_constexpr14 value_type const && value() const optional_refref_qual
{
if ( ! has_value() )
throw bad_optional_access();

return std::move( contained.value() );
return std::move( value() );
}

optional_constexpr14 value_type && value() optional_refref_qual
{
if ( ! has_value() )
throw bad_optional_access();

return std::move( contained.value() );
return std::move( value() );
}

#endif
Expand Down