From 96cd1c0163d27064bb0b36c07f44d95888ed087d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 15 Jun 2021 02:17:26 +0300 Subject: [PATCH] Add error_code comparisons against standard error code 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 776bcf4..b934a8d 100644 --- a/include/boost/system/detail/error_code.hpp +++ b/include/boost/system/detail/error_code.hpp @@ -390,6 +390,32 @@ public: return !( lhs == rhs ); } + // + + template::value>::type> + inline friend bool operator==( error_code const & lhs, E rhs ) BOOST_NOEXCEPT + { + return lhs == make_error_code( rhs ); + } + + template::value>::type> + inline friend bool operator==( E lhs, error_code const & rhs ) BOOST_NOEXCEPT + { + return make_error_code( 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