Skip to content

Commit

Permalink
Change assertions in operator* to match documentation; improves codeg…
Browse files Browse the repository at this point in the history
…en slightly in the result<U&> case
  • Loading branch information
pdimov committed Feb 24, 2025
1 parent a0597f4 commit 7a49a5d
Showing 1 changed file with 10 additions and 25 deletions.
35 changes: 10 additions & 25 deletions include/boost/system/result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,40 +332,28 @@ template<class T, class E = error_code> class result

BOOST_CXX14_CONSTEXPR T& operator*() noexcept
{
T* p = operator->();

BOOST_ASSERT( p != 0 );

return *p;
BOOST_ASSERT( has_value() );
return *operator->();
}

BOOST_CXX14_CONSTEXPR T const& operator*() const noexcept
{
T const* p = operator->();

BOOST_ASSERT( p != 0 );

return *p;
BOOST_ASSERT( has_value() );
return *operator->();
}

#else

BOOST_CXX14_CONSTEXPR T& operator*() & noexcept
{
T* p = operator->();

BOOST_ASSERT( p != 0 );

return *p;
BOOST_ASSERT( has_value() );
return *operator->();
}

BOOST_CXX14_CONSTEXPR T const& operator*() const & noexcept
{
T const* p = operator->();

BOOST_ASSERT( p != 0 );

return *p;
BOOST_ASSERT( has_value() );
return *operator->();
}

template<class U = T>
Expand Down Expand Up @@ -838,11 +826,8 @@ template<class U, class E> class result<U&, E>

BOOST_CXX14_CONSTEXPR U& operator*() const noexcept
{
U* p = operator->();

BOOST_ASSERT( p != 0 );

return *p;
BOOST_ASSERT( has_value() );
return *operator->();
}

// error access
Expand Down

0 comments on commit 7a49a5d

Please sign in to comment.