From 3164b387a5bfb900900d8cd4c9099cc6a76b4abb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 27 Feb 2019 21:10:57 +0200 Subject: [PATCH] Revert operator bool() to its pre-failed value() != 0 meaning --- doc/system/reference.adoc | 4 ++-- include/boost/system/error_code.hpp | 12 ++++++------ test/failed_test.cpp | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/system/reference.adoc b/doc/system/reference.adoc index 7116343..a0cd875 100644 --- a/doc/system/reference.adoc +++ b/doc/system/reference.adoc @@ -626,7 +626,7 @@ constexpr explicit operator bool() const noexcept; [none] * {blank} + -Returns: :: `failed()`. +Returns: :: `val_ != 0`. ``` operator std::error_code() const; @@ -789,7 +789,7 @@ constexpr explicit operator bool() const noexcept; [none] * {blank} + -Returns: :: `failed()`. +Returns: :: `val_ != 0`. ``` operator std::error_condition() const; diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index d0c2735..93899df 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -499,7 +499,7 @@ public: BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error { - return failed_; + return val_ != 0; } #else @@ -509,12 +509,12 @@ public: BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error { - return failed_? unspecified_bool_true: 0; + return val_ != 0? unspecified_bool_true: 0; } BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error { - return !failed_; + return val_ == 0; } #endif @@ -640,7 +640,7 @@ public: BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error { - return failed_; + return val_ != 0; } #else @@ -650,12 +650,12 @@ public: BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error { - return failed_? unspecified_bool_true: 0; + return val_ != 0? unspecified_bool_true: 0; } BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error { - return !failed_; + return val_ == 0; } #endif diff --git a/test/failed_test.cpp b/test/failed_test.cpp index 118d35f..142d6ef 100644 --- a/test/failed_test.cpp +++ b/test/failed_test.cpp @@ -123,13 +123,13 @@ template void test() { Ec ec( 0, http_category() ); - TEST_FAILED( ec ); + BOOST_TEST( ec.failed() ); ec.assign( 200, http_category() ); - TEST_NOT_FAILED( ec ); + BOOST_TEST( !ec.failed() ); ec = Ec( 404, http_category() ); - TEST_FAILED( ec ); + BOOST_TEST( ec.failed() ); } }