From 7d9eb384c6e7d72632a1fb46c74626125932dc33 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 12 Jun 2021 04:52:21 +0300 Subject: [PATCH] Make error_category comparisons inline friends, to avoid clang 'member call on mutable' constexpr errors --- include/boost/system/detail/error_category.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/boost/system/detail/error_category.hpp b/include/boost/system/detail/error_category.hpp index b44dd4d..07c0aa7 100644 --- a/include/boost/system/detail/error_category.hpp +++ b/include/boost/system/detail/error_category.hpp @@ -124,24 +124,24 @@ public: return ev != 0; } - BOOST_SYSTEM_CONSTEXPR bool operator==( const error_category & rhs ) const BOOST_NOEXCEPT + friend BOOST_SYSTEM_CONSTEXPR bool operator==( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT { - return rhs.id_ == 0? this == &rhs: id_ == rhs.id_; + return rhs.id_ == 0? &lhs == &rhs: lhs.id_ == rhs.id_; } - BOOST_SYSTEM_CONSTEXPR bool operator!=( const error_category & rhs ) const BOOST_NOEXCEPT + friend BOOST_SYSTEM_CONSTEXPR bool operator!=( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT { - return !( *this == rhs ); + return !( lhs == rhs ); } - BOOST_SYSTEM_CONSTEXPR bool operator<( const error_category & rhs ) const BOOST_NOEXCEPT + friend BOOST_SYSTEM_CONSTEXPR bool operator<( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT { - if( id_ < rhs.id_ ) + if( lhs.id_ < rhs.id_ ) { return true; } - if( id_ > rhs.id_ ) + if( lhs.id_ > rhs.id_ ) { return false; } @@ -151,7 +151,7 @@ public: return false; // equal } - return std::less()( this, &rhs ); + return std::less()( &lhs, &rhs ); } #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)