From 5d3365717e0fd8f95c971afe3d9432781b79494d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 16 Jun 2020 20:24:23 +0300 Subject: [PATCH] Revert "Revert operator bool() to its pre-failed value() != 0 meaning" This reverts commit 3164b387a5bfb900900d8cd4c9099cc6a76b4abb. --- 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 a0cd875..7116343 100644 --- a/doc/system/reference.adoc +++ b/doc/system/reference.adoc @@ -626,7 +626,7 @@ constexpr explicit operator bool() const noexcept; [none] * {blank} + -Returns: :: `val_ != 0`. +Returns: :: `failed()`. ``` operator std::error_code() const; @@ -789,7 +789,7 @@ constexpr explicit operator bool() const noexcept; [none] * {blank} + -Returns: :: `val_ != 0`. +Returns: :: `failed()`. ``` operator std::error_condition() const; diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index df80592..70433ac 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -515,7 +515,7 @@ public: BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error { - return val_ != 0; + return failed_; } #else @@ -525,12 +525,12 @@ public: BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error { - return val_ != 0? unspecified_bool_true: 0; + return failed_? unspecified_bool_true: 0; } BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error { - return val_ == 0; + return !failed_; } #endif @@ -656,7 +656,7 @@ public: BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error { - return val_ != 0; + return failed_; } #else @@ -666,12 +666,12 @@ public: BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error { - return val_ != 0? unspecified_bool_true: 0; + return failed_? unspecified_bool_true: 0; } BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error { - return val_ == 0; + return !failed_; } #endif diff --git a/test/failed_test.cpp b/test/failed_test.cpp index 142d6ef..118d35f 100644 --- a/test/failed_test.cpp +++ b/test/failed_test.cpp @@ -123,13 +123,13 @@ template void test() { Ec ec( 0, http_category() ); - BOOST_TEST( ec.failed() ); + TEST_FAILED( ec ); ec.assign( 200, http_category() ); - BOOST_TEST( !ec.failed() ); + TEST_NOT_FAILED( ec ); ec = Ec( 404, http_category() ); - BOOST_TEST( ec.failed() ); + TEST_FAILED( ec ); } }