diff --git a/include/boost/system/detail/config.hpp b/include/boost/system/detail/config.hpp index 1855aa1..26e0a4c 100644 --- a/include/boost/system/detail/config.hpp +++ b/include/boost/system/detail/config.hpp @@ -1,7 +1,7 @@ #ifndef BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED #define BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED -// Copyright 2018 Peter Dimov +// Copyright 2018-2022 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -62,4 +62,20 @@ # define BOOST_SYSTEM_CLANG_6 #endif +// + +#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 50000 +# define BOOST_SYSTEM_AVOID_STD_GENERIC_CATEGORY +#endif + +#if defined(__CYGWIN__) || defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER == 1800) || (defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 90000) + +// Under Cygwin (and MinGW!), std::system_category() is POSIX +// Under VS2013, std::system_category() isn't quite right +// Under libstdc++ before 7.4, before 8.3, before 9.1, default_error_condition +// for the system category returns a condition from the system category + +# define BOOST_SYSTEM_AVOID_STD_SYSTEM_CATEGORY +#endif + #endif // BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED diff --git a/include/boost/system/detail/error_category_impl.hpp b/include/boost/system/detail/error_category_impl.hpp index 07101c1..e37d4ba 100644 --- a/include/boost/system/detail/error_category_impl.hpp +++ b/include/boost/system/detail/error_category_impl.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -108,7 +109,7 @@ inline error_category::operator std::error_category const & () const if( id_ == detail::generic_category_id ) { // This condition must be the same as the one in error_condition.hpp -#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 50000 +#if defined(BOOST_SYSTEM_AVOID_STD_GENERIC_CATEGORY) static const boost::system::detail::std_category generic_instance( this, 0x1F4D3 ); return generic_instance; @@ -123,12 +124,7 @@ inline error_category::operator std::error_category const & () const if( id_ == detail::system_category_id ) { // This condition must be the same as the one in error_code.hpp -#if defined(__CYGWIN__) || defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER == 1800) || (defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 90000) - - // Under Cygwin (and MinGW!), std::system_category() is POSIX - // Under VS2013, std::system_category() isn't quite right - // Under libstdc++ before 7.4, before 8.3, before 9.1, default_error_condition - // for the system category returns a condition from the system category +#if defined(BOOST_SYSTEM_AVOID_STD_SYSTEM_CATEGORY) static const boost::system::detail::std_category system_instance( this, 0x1F4D7 ); return system_instance; diff --git a/include/boost/system/detail/error_code.hpp b/include/boost/system/detail/error_code.hpp index f7d9d30..587b3ab 100644 --- a/include/boost/system/detail/error_code.hpp +++ b/include/boost/system/detail/error_code.hpp @@ -575,7 +575,7 @@ public: else if( lc_flags_ == 0 ) { // This condition must be the same as the one in error_category_impl.hpp -#if defined(__CYGWIN__) || defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER == 1800) || (defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 90000) +#if defined(BOOST_SYSTEM_AVOID_STD_SYSTEM_CATEGORY) return std::error_code( 0, boost::system::system_category() ); diff --git a/include/boost/system/detail/error_condition.hpp b/include/boost/system/detail/error_condition.hpp index b54498b..a7e35ab 100644 --- a/include/boost/system/detail/error_condition.hpp +++ b/include/boost/system/detail/error_condition.hpp @@ -223,7 +223,7 @@ public: operator std::error_condition () const { // This condition must be the same as the one in error_category_impl.hpp -#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 50000 +#if defined(BOOST_SYSTEM_AVOID_STD_GENERIC_CATEGORY) return std::error_condition( value(), category() );