From 6ec468aff6d8dea7b0fcc52962fbe6bf90e4511f Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Thu, 15 Aug 2024 10:57:03 +0200 Subject: [PATCH] Drop explicit bool idiom --- include/boost/optional/detail/optional_reference_spec.hpp | 3 +-- include/boost/optional/optional.hpp | 1 - test/optional_test_convert_assign.cpp | 3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/include/boost/optional/detail/optional_reference_spec.hpp b/include/boost/optional/detail/optional_reference_spec.hpp index 3be3d33..4940a46 100644 --- a/include/boost/optional/detail/optional_reference_spec.hpp +++ b/include/boost/optional/detail/optional_reference_spec.hpp @@ -160,8 +160,7 @@ public: throw_exception(bad_optional_access()); } - bool operator!() const BOOST_NOEXCEPT { return ptr_ == 0; } - BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT() + explicit operator bool() const BOOST_NOEXCEPT { return ptr_ != 0; } void reset() BOOST_NOEXCEPT { ptr_ = 0; } diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp index 57ff8ef..72fbd60 100644 --- a/include/boost/optional/optional.hpp +++ b/include/boost/optional/optional.hpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include diff --git a/test/optional_test_convert_assign.cpp b/test/optional_test_convert_assign.cpp index f0366dc..5e1ceda 100644 --- a/test/optional_test_convert_assign.cpp +++ b/test/optional_test_convert_assign.cpp @@ -25,8 +25,7 @@ struct implicit_bool_conv struct explicit_bool_conv { - bool operator!() const BOOST_NOEXCEPT { return false; } - BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT() + explicit operator bool() const BOOST_NOEXCEPT { return true; } }; template