Rename std_interoperability.hpp to to_std_category.hpp, make it self-contained

This commit is contained in:
Peter Dimov
2020-08-28 01:03:15 +03:00
parent 7d6da0ad91
commit 776834b723
3 changed files with 22 additions and 3 deletions

View File

@@ -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:

View File

@@ -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 <boost/system/detail/std_interoperability.hpp>
#include <boost/system/detail/to_std_category.hpp>
inline boost::system::error_category::operator std::error_category const & () const
{

View File

@@ -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 <system_error>
//
// Copyright 2018 Peter Dimov
@@ -7,6 +10,10 @@
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/detail/error_category.hpp>
#include <boost/system/detail/error_condition.hpp>
#include <boost/system/detail/error_code.hpp>
#include <boost/system/detail/generic_category.hpp>
#include <system_error>
#include <map>
#include <memory>
@@ -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