diff --git a/include/boost/system/detail/error_category.hpp b/include/boost/system/detail/error_category.hpp index 2226678..5aa0c38 100644 --- a/include/boost/system/detail/error_category.hpp +++ b/include/boost/system/detail/error_category.hpp @@ -38,6 +38,12 @@ namespace detail BOOST_SYSTEM_CONSTEXPR bool failed_impl( int ev, error_category const & cat ); +#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) + +std::error_category const & to_std_category( error_category const & cat ); + +#endif + } // namespace detail #if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG ) @@ -52,6 +58,10 @@ private: friend std::size_t hash_value( error_code const & ec ); friend BOOST_SYSTEM_CONSTEXPR bool detail::failed_impl( int ev, error_category const & cat ); +#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) + friend std::error_category const & detail::to_std_category( error_category const & cat ); +#endif + #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) public: diff --git a/include/boost/system/detail/error_category_impl.hpp b/include/boost/system/detail/error_category_impl.hpp index 252f845..35cba4b 100644 --- a/include/boost/system/detail/error_category_impl.hpp +++ b/include/boost/system/detail/error_category_impl.hpp @@ -96,7 +96,7 @@ inline char const * error_category::message( int ev, char * buffer, std::size_t #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) -#include +#include inline boost::system::error_category::operator std::error_category const & () const { diff --git a/include/boost/system/detail/std_interoperability.hpp b/include/boost/system/detail/to_std_category.hpp similarity index 90% rename from include/boost/system/detail/std_interoperability.hpp rename to include/boost/system/detail/to_std_category.hpp index 66ebecb..3151f5c 100644 --- a/include/boost/system/detail/std_interoperability.hpp +++ b/include/boost/system/detail/to_std_category.hpp @@ -1,3 +1,6 @@ +#ifndef BOOST_SYSTEM_DETAIL_TO_STD_CATEGORY_HPP_INCLUDED +#define BOOST_SYSTEM_DETAIL_TO_STD_CATEGORY_HPP_INCLUDED + // Support for interoperability between Boost.System and // // Copyright 2018 Peter Dimov @@ -7,6 +10,10 @@ // // See library home page at http://www.boost.org/libs/system +#include +#include +#include +#include #include #include #include @@ -80,12 +87,12 @@ struct cat_ptr_less inline std::error_category const & to_std_category( boost::system::error_category const & cat ) { - if( cat == boost::system::system_category() ) + if( cat.id_ == boost::system::detail::system_category_id ) { static const std_category system_instance( &cat, 0x1F4D7 ); return system_instance; } - else if( cat == boost::system::generic_category() ) + else if( cat.id_ == boost::system::detail::generic_category_id ) { static const std_category generic_instance( &cat, 0x1F4D3 ); return generic_instance; @@ -180,3 +187,5 @@ inline bool std_category::equivalent( const std::error_code & code, int conditio } // namespace system } // namespace boost + +#endif // #ifndef BOOST_SYSTEM_DETAIL_TO_STD_CATEGORY_HPP_INCLUDED