Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions include/boost/optional/detail/optional_reference_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ class optional<T&> : public optional_detail::optional_tag

constexpr T& value() const
{
return this->is_initialized() ?
this->get() :
(boost::throw_exception(boost::bad_optional_access()), this->get());
if (!this->is_initialized()) {
boost::throw_exception(boost::bad_optional_access());
}
return this->get();
}

constexpr explicit operator bool() const BOOST_NOEXCEPT { return ptr_ != 0; }
Expand Down
5 changes: 4 additions & 1 deletion include/boost/optional/detail/union_optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,10 @@ namespace boost {

constexpr reference_const_type value() const&
{
return this->is_initialized() ? this->get() : (boost::throw_exception(boost::bad_optional_access()), this->get());
if (this->is_initialized())
return this->get();
else
boost::throw_exception(boost::bad_optional_access());
}

BOOST_CXX14_CONSTEXPR reference_type value() &
Expand Down