Add test for std interop; implement equivalent

This commit is contained in:
Peter Dimov
2017-05-20 14:33:54 +03:00
parent 6010be4144
commit 044c0565b9
3 changed files with 217 additions and 10 deletions

View File

@@ -238,6 +238,7 @@ namespace boost
}
virtual std::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT;
virtual bool equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT;
};
std_category std_cat_;
@@ -248,7 +249,7 @@ namespace boost
operator std::error_category const & () const BOOST_SYSTEM_NOEXCEPT
{
if( this == &generic_category() )
if( *this == generic_category() )
{
return std::generic_category();
}
@@ -376,15 +377,6 @@ namespace boost
};
#ifndef BOOST_NO_CXX11_HDR_SYSTEM_ERROR
inline std::error_condition error_category::std_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
{
return pc_->default_error_condition( ev );
}
#endif
// class error_code ----------------------------------------------------//
// We want error_code to be a value type that can be copied without slicing
@@ -601,6 +593,27 @@ namespace boost
return *this == code.category() && code.value() == condition;
}
#ifndef BOOST_NO_CXX11_HDR_SYSTEM_ERROR
inline std::error_condition error_category::std_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
{
return pc_->default_error_condition( ev );
}
inline bool error_category::std_category::equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT
{
if( condition.category() == std::generic_category() )
{
return pc_->equivalent( code, boost::system::error_condition( condition.value(), boost::system::generic_category() ) );
}
else
{
return default_error_condition( code ) == condition;
}
}
#endif
} // namespace system
} // namespace boost