forked from boostorg/system
Do not map system::generic to std::generic directly
This commit is contained in:
@ -250,22 +250,9 @@ namespace boost
|
||||
|
||||
operator std::error_category const & () const BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
if( *this == generic_category() )
|
||||
{
|
||||
std::error_category const & st = std::generic_category();
|
||||
|
||||
int ev = ENOENT;
|
||||
|
||||
// if the standard generic category works, use it; else not
|
||||
if( st.equivalent( ev, st.default_error_condition( ev ) ) )
|
||||
{
|
||||
// g++ 4.x with libstdc++ 5 installed fails, because the two
|
||||
// generic categories, v1 and v2, get mixed up
|
||||
|
||||
return st;
|
||||
}
|
||||
}
|
||||
|
||||
// do not map generic to std::generic on purpose; occasionally,
|
||||
// there are two std::generic categories in a program, which leads
|
||||
// to error codes/conditions mysteriously not being equal to themselves
|
||||
return std_cat_;
|
||||
}
|
||||
|
||||
@ -618,7 +605,7 @@ namespace boost
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if( condition.category() == std::generic_category() )
|
||||
else if( condition.category() == std::generic_category() || condition.category() == boost::system::generic_category() )
|
||||
{
|
||||
return pc_->equivalent( code, boost::system::error_condition( condition.value(), boost::system::generic_category() ) );
|
||||
}
|
||||
|
@ -24,28 +24,14 @@ int main() {}
|
||||
|
||||
static void test_generic_category()
|
||||
{
|
||||
int ev = ENOENT;
|
||||
|
||||
// check whether the standard generic category works
|
||||
|
||||
std::error_category const & st0 = std::generic_category();
|
||||
bool has_roundtrip = st0.equivalent( ev, st0.default_error_condition( ev ) );
|
||||
|
||||
//
|
||||
|
||||
boost::system::error_category const & bt = boost::system::generic_category();
|
||||
std::error_category const & st = bt;
|
||||
|
||||
BOOST_TEST_CSTR_EQ( bt.name(), st.name() );
|
||||
|
||||
if( has_roundtrip )
|
||||
{
|
||||
BOOST_TEST_EQ( &st, &std::generic_category() );
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) );
|
||||
}
|
||||
int ev = ENOENT;
|
||||
|
||||
BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) );
|
||||
|
||||
{
|
||||
boost::system::error_code bc( ev, bt );
|
||||
|
Reference in New Issue
Block a user