diff --git a/include/boost/system/detail/error_code.hpp b/include/boost/system/detail/error_code.hpp index 2b8766f..497c638 100644 --- a/include/boost/system/detail/error_code.hpp +++ b/include/boost/system/detail/error_code.hpp @@ -300,6 +300,48 @@ public: return !( lhs == rhs ); } + inline friend bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT + { +#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) + + if( code.flags_ == 1 ) + { + return static_cast( code ) == static_cast( condition ); + } + else + +#endif + { + return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() ); + } + } + + inline friend bool operator==( const error_condition & condition, const error_code & code ) BOOST_NOEXCEPT + { +#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) + + if( code.flags_ == 1 ) + { + return static_cast( code ) == static_cast( condition ); + } + else + +#endif + { + return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() ); + } + } + + inline friend bool operator!=( const error_code & lhs, const error_condition & rhs ) BOOST_NOEXCEPT + { + return !( lhs == rhs ); + } + + inline friend bool operator!=( const error_condition & lhs, const error_code & rhs ) BOOST_NOEXCEPT + { + return !( lhs == rhs ); + } + #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) inline friend bool operator==( std::error_code const & lhs, error_code const & rhs ) BOOST_NOEXCEPT diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index c34c2c0..751195c 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -17,38 +17,5 @@ #include #include #include -#include - -namespace boost -{ - -namespace system -{ - -// non-member functions of error_code and error_condition - -inline bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT -{ - return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() ); -} - -inline bool operator!=( const error_code & lhs, const error_condition & rhs ) BOOST_NOEXCEPT -{ - return !( lhs == rhs ); -} - -inline bool operator==( const error_condition & condition, const error_code & code ) BOOST_NOEXCEPT -{ - return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() ); -} - -inline bool operator!=( const error_condition & lhs, const error_code & rhs ) BOOST_NOEXCEPT -{ - return !( lhs == rhs ); -} - -} // namespace system - -} // namespace boost #endif // BOOST_SYSTEM_ERROR_CODE_HPP_INCLUDED