forked from boostorg/system
Fix implicit conversion to int errors
This commit is contained in:
@@ -84,7 +84,7 @@ public:
|
||||
|
||||
template<class ErrorConditionEnum> BOOST_SYSTEM_CONSTEXPR error_condition( ErrorConditionEnum e,
|
||||
typename detail::enable_if<boost::system::detail::is_same<ErrorConditionEnum, errc::errc_t>::value>::type* = 0) BOOST_NOEXCEPT:
|
||||
val_( e ), cat_( 0 )
|
||||
val_( static_cast<int>( e ) ), cat_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -165,7 +165,7 @@ int main( int, char ** )
|
||||
econd = ec.default_error_condition();
|
||||
BOOST_TEST( econd.value() == static_cast<int>(errc::permission_denied) );
|
||||
BOOST_TEST( econd.category() == generic_category() );
|
||||
BOOST_TEST( econd == error_condition( errc::permission_denied, generic_category() ) );
|
||||
BOOST_TEST( econd == error_condition( static_cast<int>(errc::permission_denied), generic_category() ) );
|
||||
BOOST_TEST( econd == errc::permission_denied );
|
||||
BOOST_TEST( errc::permission_denied == econd );
|
||||
BOOST_TEST( ec == errc::permission_denied );
|
||||
@@ -244,35 +244,35 @@ int main( int, char ** )
|
||||
ec = error_code( ERROR_ACCESS_DENIED, system_category() );
|
||||
BOOST_TEST( ec.value() == ERROR_ACCESS_DENIED );
|
||||
BOOST_TEST( ec == errc::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().value() == static_cast<int>(errc::permission_denied) );
|
||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||
|
||||
// test the second entry in the decoder table:
|
||||
ec = error_code( ERROR_ALREADY_EXISTS, system_category() );
|
||||
BOOST_TEST( ec.value() == ERROR_ALREADY_EXISTS );
|
||||
BOOST_TEST( ec == errc::file_exists );
|
||||
BOOST_TEST( ec.default_error_condition().value() == errc::file_exists );
|
||||
BOOST_TEST( ec.default_error_condition().value() == static_cast<int>(errc::file_exists) );
|
||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||
|
||||
// test the third entry in the decoder table:
|
||||
ec = error_code( ERROR_BAD_UNIT, system_category() );
|
||||
BOOST_TEST( ec.value() == ERROR_BAD_UNIT );
|
||||
BOOST_TEST( ec == errc::no_such_device );
|
||||
BOOST_TEST( ec.default_error_condition().value() == errc::no_such_device );
|
||||
BOOST_TEST( ec.default_error_condition().value() == static_cast<int>(errc::no_such_device) );
|
||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||
|
||||
// test the last non-Winsock entry in the decoder table:
|
||||
ec = error_code( ERROR_WRITE_PROTECT, system_category() );
|
||||
BOOST_TEST( ec.value() == ERROR_WRITE_PROTECT );
|
||||
BOOST_TEST( ec == errc::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().value() == static_cast<int>(errc::permission_denied) );
|
||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||
|
||||
// test the last Winsock entry in the decoder table:
|
||||
ec = error_code( WSAEWOULDBLOCK, system_category() );
|
||||
BOOST_TEST( ec.value() == WSAEWOULDBLOCK );
|
||||
BOOST_TEST( ec == errc::operation_would_block );
|
||||
BOOST_TEST( ec.default_error_condition().value() == errc::operation_would_block );
|
||||
BOOST_TEST( ec.default_error_condition().value() == static_cast<int>(errc::operation_would_block) );
|
||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||
|
||||
// test not-in-table condition:
|
||||
@@ -289,7 +289,7 @@ int main( int, char ** )
|
||||
BOOST_TEST( error_code( errc::permission_denied, system_category() ) == ec );
|
||||
BOOST_TEST( ec == errc::permission_denied );
|
||||
BOOST_TEST( errc::permission_denied == ec );
|
||||
BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().value() == static_cast<int>(errc::permission_denied) );
|
||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||
|
||||
#endif
|
||||
|
@@ -118,7 +118,7 @@ namespace boost
|
||||
boost::system::error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return ev == boo_boo
|
||||
? boost::system::error_condition( boost::system::errc::io_error,
|
||||
? boost::system::error_condition( static_cast<int>( boost::system::errc::io_error ),
|
||||
boost::system::generic_category() )
|
||||
: boost::system::error_condition( ev,
|
||||
boost::lib3::lib3_error_category );
|
||||
@@ -180,7 +180,7 @@ namespace lib4
|
||||
boost::system::error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return ev == boo_boo.value()
|
||||
? boost::system::error_condition( boost::system::errc::io_error,
|
||||
? boost::system::error_condition( static_cast<int>( boost::system::errc::io_error ),
|
||||
boost::system::generic_category() )
|
||||
: boost::system::error_condition( ev, lib4::lib4_error_category );
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ struct foo
|
||||
foo()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
BOOST_TEST_NE( ec, boost::system::errc::permission_denied );
|
||||
BOOST_TEST( ec != boost::system::errc::permission_denied );
|
||||
}
|
||||
} f;
|
||||
|
||||
|
Reference in New Issue
Block a user