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

Add rvalue ref overload for get() #56

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions include/boost/optional/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1197,8 +1197,14 @@ class optional
// Returns a reference to the value if this is initialized, otherwise,
// the behaviour is UNDEFINED
// No-throw
#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
reference_const_type get() const& { BOOST_ASSERT(this->is_initialized()) ; return this->get_impl(); }
reference_type get() & { BOOST_ASSERT(this->is_initialized()) ; return this->get_impl(); }
reference_type_of_temporary_wrapper get() && { BOOST_ASSERT(this->is_initialized()) ; return boost::move(this->get_impl()); }
#else
reference_const_type get() const { BOOST_ASSERT(this->is_initialized()) ; return this->get_impl(); }
reference_type get() { BOOST_ASSERT(this->is_initialized()) ; return this->get_impl(); }
#endif // !defined BOOST_NO_CXX11_REF_QUALIFIERS

// Returns a copy of the value if this is initialized, 'v' otherwise
reference_const_type get_value_or ( reference_const_type v ) const { return this->is_initialized() ? get() : v ; }
Expand Down