#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
# include <system_error>
+# include <atomic>
#endif
namespace boost
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
+class std_category;
} // namespace detail
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
+ friend class error_code;
+ friend class error_condition;
#if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
public:
boost::ulong_long_type id_;
+#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
+
+ mutable std::atomic< boost::system::detail::std_category* > ps_;
+
+#else
+
+ boost::system::detail::std_category* ps_;
+
+#endif
+
protected:
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
#endif
- BOOST_SYSTEM_CONSTEXPR error_category() BOOST_NOEXCEPT: id_( 0 )
+ BOOST_SYSTEM_CONSTEXPR error_category() BOOST_NOEXCEPT: id_( 0 ), ps_()
{
}
- explicit BOOST_SYSTEM_CONSTEXPR error_category( boost::ulong_long_type id ) BOOST_NOEXCEPT: id_( id )
+ explicit BOOST_SYSTEM_CONSTEXPR error_category( boost::ulong_long_type id ) BOOST_NOEXCEPT: id_( id ), ps_()
{
}
return ev != 0;
}
- BOOST_SYSTEM_CONSTEXPR bool operator==( const error_category & rhs ) const BOOST_NOEXCEPT
+ friend BOOST_SYSTEM_CONSTEXPR bool operator==( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT
{
- return rhs.id_ == 0? this == &rhs: id_ == rhs.id_;
+ return rhs.id_ == 0? &lhs == &rhs: lhs.id_ == rhs.id_;
}
- BOOST_SYSTEM_CONSTEXPR bool operator!=( const error_category & rhs ) const BOOST_NOEXCEPT
+ friend BOOST_SYSTEM_CONSTEXPR bool operator!=( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT
{
- return !( *this == rhs );
+ return !( lhs == rhs );
}
- BOOST_SYSTEM_CONSTEXPR bool operator<( const error_category & rhs ) const BOOST_NOEXCEPT
+ friend BOOST_SYSTEM_CONSTEXPR bool operator<( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT
{
- if( id_ < rhs.id_ )
+ if( lhs.id_ < rhs.id_ )
{
return true;
}
- if( id_ > rhs.id_ )
+ if( lhs.id_ > rhs.id_ )
{
return false;
}
return false; // equal
}
- return std::less<error_category const *>()( this, &rhs );
+ return std::less<error_category const *>()( &lhs, &rhs );
}
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
-
+# if defined(__SUNPRO_CC) // trailing __global is not supported
operator std::error_category const & () const;
-
+# else
+ operator std::error_category const & () const BOOST_SYMBOL_VISIBLE;
+# endif
#endif
};
namespace detail
{
-static const boost::ulong_long_type generic_category_id = ( boost::ulong_long_type( 0xB2AB117A ) << 32 ) + 0x257EDF0D;
-static const boost::ulong_long_type system_category_id = ( boost::ulong_long_type( 0x8FAFD21E ) << 32 ) + 0x25C5E09B;
+static const boost::ulong_long_type generic_category_id = ( boost::ulong_long_type( 0xB2AB117A ) << 32 ) + 0x257EDFD0;
+static const boost::ulong_long_type system_category_id = generic_category_id + 1;
+static const boost::ulong_long_type interop_category_id = generic_category_id + 2;
BOOST_SYSTEM_CONSTEXPR inline bool failed_impl( int ev, error_category const & cat )
{