mirror of
https://github.com/boostorg/system.git
synced 2025-07-31 04:57:13 +02:00
Try to fix g++ 4.x issue with generic_category
This commit is contained in:
@ -251,7 +251,18 @@ namespace boost
|
|||||||
{
|
{
|
||||||
if( *this == generic_category() )
|
if( *this == generic_category() )
|
||||||
{
|
{
|
||||||
return std::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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return std_cat_;
|
return std_cat_;
|
||||||
|
@ -24,15 +24,28 @@ int main() {}
|
|||||||
|
|
||||||
static void test_generic_category()
|
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();
|
boost::system::error_category const & bt = boost::system::generic_category();
|
||||||
std::error_category const & st = bt;
|
std::error_category const & st = bt;
|
||||||
|
|
||||||
BOOST_TEST_EQ( &st, &std::generic_category() );
|
|
||||||
|
|
||||||
BOOST_TEST_CSTR_EQ( bt.name(), st.name() );
|
BOOST_TEST_CSTR_EQ( bt.name(), st.name() );
|
||||||
|
|
||||||
int ev = ENOENT;
|
if( has_roundtrip )
|
||||||
// BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) );
|
{
|
||||||
|
BOOST_TEST_EQ( &st, &std::generic_category() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) );
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::system::error_code bc( ev, bt );
|
boost::system::error_code bc( ev, bt );
|
||||||
@ -60,13 +73,6 @@ static void test_generic_category()
|
|||||||
BOOST_TEST_EQ( &sn.category(), &st );
|
BOOST_TEST_EQ( &sn.category(), &st );
|
||||||
|
|
||||||
BOOST_TEST( st.equivalent( ev, sn ) );
|
BOOST_TEST( st.equivalent( ev, sn ) );
|
||||||
|
|
||||||
std::error_condition sn2 = st.default_error_condition( ev );
|
|
||||||
|
|
||||||
BOOST_TEST_EQ( sn2.value(), ev );
|
|
||||||
BOOST_TEST_EQ( &sn2.category(), &st );
|
|
||||||
|
|
||||||
BOOST_TEST( st.equivalent( ev, sn2 ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user