From bc193d7adde655622021eb1829a19efb68fbd9a3 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sat, 16 Mar 2013 12:00:01 +0000 Subject: [PATCH] Fix GCC-4.6.x support which was broken in last commit. Refs #8292 [SVN r83459] --- include/boost/multiprecision/number.hpp | 40 ++++++++++--------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/include/boost/multiprecision/number.hpp b/include/boost/multiprecision/number.hpp index b61ed079..039ce6a5 100644 --- a/include/boost/multiprecision/number.hpp +++ b/include/boost/multiprecision/number.hpp @@ -538,22 +538,6 @@ public: eval_bitwise_xor(m_backend, canonical_value(v)); return *this; } - // - // Use in boolean context: - // -#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS - BOOST_MP_FORCEINLINE explicit operator bool()const - { - return !is_zero(); - } -#else - typedef bool (self_type::*unmentionable_type)()const; - - BOOST_MP_FORCEINLINE operator unmentionable_type()const - { - return is_zero() ? 0 : &self_type::is_zero; - } -#endif // // swap: // @@ -605,8 +589,11 @@ public: convert_to_imp(&result); return result; } + // + // Use in boolean context, and explicit conversion operators: + // #ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS -#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7) +# if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7) // // Horrible workaround for gcc-4.6.x which always prefers the template // operator bool() rather than the non-template operator when converting to @@ -623,20 +610,25 @@ public: { return this->template convert_to(); } -#else +# else template explicit operator T()const { return this->template convert_to(); } - /* - explicit operator bool()const + BOOST_MP_FORCEINLINE explicit operator bool()const { - using default_ops::eval_is_zero; - return !eval_is_zero(backend()); - }*/ + return !is_zero(); + } explicit operator void()const {} -#endif +# endif +#else + typedef bool (self_type::*unmentionable_type)()const; + + BOOST_MP_FORCEINLINE operator unmentionable_type()const + { + return is_zero() ? 0 : &self_type::is_zero; + } #endif // // Default precision: