From f26dfd3dd7bb9b4a77adfc905610d2c540d9b552 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 15 Jun 2021 01:52:32 +0300 Subject: [PATCH] Add error_code comparisons against standard error condition enums (to resolve the ambiguity when an enum is both standard and ours) --- include/boost/system/detail/error_code.hpp | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/boost/system/detail/error_code.hpp b/include/boost/system/detail/error_code.hpp index 0626847..776bcf4 100644 --- a/include/boost/system/detail/error_code.hpp +++ b/include/boost/system/detail/error_code.hpp @@ -364,6 +364,32 @@ public: return !( lhs == rhs ); } + // + + template::value>::type> + inline friend bool operator==( error_code const & lhs, E rhs ) BOOST_NOEXCEPT + { + return lhs == make_error_condition( rhs ); + } + + template::value>::type> + inline friend bool operator==( E lhs, error_code const & rhs ) BOOST_NOEXCEPT + { + return make_error_condition( lhs ) == rhs; + } + + template::value>::type> + inline friend bool operator!=( error_code const & lhs, E rhs ) BOOST_NOEXCEPT + { + return !( lhs == rhs ); + } + + template::value>::type> + inline friend bool operator!=( E lhs, error_code const & rhs ) BOOST_NOEXCEPT + { + return !( lhs == rhs ); + } + #if defined(BOOST_SYSTEM_CLANG_6) inline friend bool operator==( error_code const & lhs, std::error_condition const & rhs ) BOOST_NOEXCEPT