mirror of
https://github.com/boostorg/system.git
synced 2025-07-30 12:37:13 +02:00
Revert "Mark error_condition::failed, error_condition::message as deprecated; revert op bool"
This reverts commit 329e72fb92
.
This commit is contained in:
@ -45,6 +45,7 @@ class error_condition
|
||||
private:
|
||||
|
||||
int val_;
|
||||
bool failed_;
|
||||
error_category const * cat_;
|
||||
|
||||
public:
|
||||
@ -52,12 +53,12 @@ public:
|
||||
// constructors:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_condition() BOOST_NOEXCEPT:
|
||||
val_( 0 ), cat_( 0 )
|
||||
val_( 0 ), failed_( false ), cat_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_condition( int val, const error_category & cat ) BOOST_NOEXCEPT:
|
||||
val_( val ), cat_( &cat )
|
||||
val_( val ), failed_( detail::failed_impl( val, cat ) ), cat_( &cat )
|
||||
{
|
||||
}
|
||||
|
||||
@ -85,6 +86,7 @@ public:
|
||||
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
|
||||
{
|
||||
val_ = val;
|
||||
failed_ = detail::failed_impl( val, cat );
|
||||
cat_ = &cat;
|
||||
}
|
||||
|
||||
@ -99,6 +101,7 @@ public:
|
||||
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
|
||||
{
|
||||
val_ = 0;
|
||||
failed_ = false;
|
||||
cat_ = 0;
|
||||
}
|
||||
|
||||
@ -140,21 +143,14 @@ public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
||||
{
|
||||
if( cat_ )
|
||||
{
|
||||
return detail::failed_impl( val_, *cat_ );
|
||||
}
|
||||
else
|
||||
{
|
||||
return val_ != 0;
|
||||
}
|
||||
return failed_;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
|
||||
{
|
||||
return failed();
|
||||
return failed_;
|
||||
}
|
||||
|
||||
#else
|
||||
@ -164,12 +160,12 @@ public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
|
||||
{
|
||||
return failed()? unspecified_bool_true: 0;
|
||||
return failed_? unspecified_bool_true: 0;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
|
||||
{
|
||||
return !failed();
|
||||
return !failed_;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -120,30 +120,18 @@ template<class Ec> void test()
|
||||
ec.assign( 0, generic_category() );
|
||||
TEST_NOT_FAILED( ec );
|
||||
}
|
||||
}
|
||||
|
||||
template<class Ec> void test2()
|
||||
{
|
||||
Ec ec( 0, http_category() );
|
||||
TEST_FAILED( ec );
|
||||
{
|
||||
Ec ec( 0, http_category() );
|
||||
TEST_FAILED( ec );
|
||||
|
||||
ec.assign( 200, http_category() );
|
||||
TEST_NOT_FAILED( ec );
|
||||
ec.assign( 200, http_category() );
|
||||
TEST_NOT_FAILED( ec );
|
||||
|
||||
ec = Ec( 404, http_category() );
|
||||
TEST_FAILED( ec );
|
||||
}
|
||||
ec = Ec( 404, http_category() );
|
||||
TEST_FAILED( ec );
|
||||
}
|
||||
|
||||
template<class Ec> void test3()
|
||||
{
|
||||
Ec ec( 0, http_category() );
|
||||
BOOST_TEST( ec.failed() );
|
||||
|
||||
ec.assign( 200, http_category() );
|
||||
BOOST_TEST( !ec.failed() );
|
||||
|
||||
ec = Ec( 404, http_category() );
|
||||
BOOST_TEST( ec.failed() );
|
||||
}
|
||||
|
||||
int main()
|
||||
@ -159,9 +147,7 @@ int main()
|
||||
BOOST_TEST( http_category().failed( 404 ) );
|
||||
|
||||
test<error_code>();
|
||||
test2<error_code>();
|
||||
test<error_condition>();
|
||||
test3<error_condition>();
|
||||
|
||||
{
|
||||
error_condition ec( errc::success );
|
||||
|
Reference in New Issue
Block a user