Use explicit operator bool when available

This commit is contained in:
Peter Dimov
2018-03-31 21:11:57 +03:00
committed by James E. King III
parent bffcf0c4db
commit 23cd89d4c8

View File

@ -109,11 +109,22 @@ public:
* \returns true if the 3-state boolean is true, false otherwise * \returns true if the 3-state boolean is true, false otherwise
* \throws nothrow * \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 BOOST_CONSTEXPR operator safe_bool() const BOOST_NOEXCEPT
{ {
return value == true_value? &dummy::nonnull : 0; return value == true_value? &dummy::nonnull : 0;
} }
#endif
/** /**
* The actual stored value in this 3-state boolean, which may be false, true, * The actual stored value in this 3-state boolean, which may be false, true,
* or indeterminate. * or indeterminate.