From 23cd89d4c80ff00886dbaa5962a3777e8ead33ea Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 31 Mar 2018 21:11:57 +0300 Subject: [PATCH] Use explicit operator bool when available --- include/boost/logic/tribool.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/boost/logic/tribool.hpp b/include/boost/logic/tribool.hpp index c4788c1..0111a4f 100644 --- a/include/boost/logic/tribool.hpp +++ b/include/boost/logic/tribool.hpp @@ -109,11 +109,22 @@ public: * \returns true if the 3-state boolean is true, false otherwise * \throws nothrow */ +#if !defined( BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS ) + + BOOST_CONSTEXPR explicit operator bool () const BOOST_NOEXCEPT + { + return value == true_value; + } + +#else + BOOST_CONSTEXPR operator safe_bool() const BOOST_NOEXCEPT { return value == true_value? &dummy::nonnull : 0; } +#endif + /** * The actual stored value in this 3-state boolean, which may be false, true, * or indeterminate.