|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r80237 - sandbox/big_number/boost/multiprecision
From: john_at_[hidden]
Date: 2012-08-26 12:46:45
Author: johnmaddock
Date: 2012-08-26 12:46:44 EDT (Sun, 26 Aug 2012)
New Revision: 80237
URL: http://svn.boost.org/trac/boost/changeset/80237
Log:
Fix explicit conversion operators for GCC-4.6.x
Text files modified:
sandbox/big_number/boost/multiprecision/number.hpp | 39 +++++++++++++++++++++++++++++----------
1 files changed, 29 insertions(+), 10 deletions(-)
Modified: sandbox/big_number/boost/multiprecision/number.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/number.hpp (original)
+++ sandbox/big_number/boost/multiprecision/number.hpp 2012-08-26 12:46:44 EDT (Sun, 26 Aug 2012)
@@ -598,16 +598,35 @@
return result;
}
#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
-template <class T>
-explicit operator T()const
-{
- return this->template convert_to<T>();
-}
-explicit operator bool()const
-{
- using default_ops::eval_is_zero;
- return !eval_is_zero(backend());
-}
+#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7)
+ //
+ // Horrible workaround for gcc-4.6.x which always prefers the non-template
+ // operator bool() rather than the template operator when converting to
+ // an arithmetic type:
+ //
+ template <class T, typename enable_if<is_same<T, bool>, int>::type = 0>
+ explicit operator T ()const
+ {
+ using default_ops::eval_is_zero;
+ return !eval_is_zero(backend());
+ }
+ template <class T, typename disable_if<is_same<T, bool>, int>::type = 0>
+ explicit operator T ()const
+ {
+ return this->template convert_to<T>();
+ }
+#else
+ template <class T>
+ explicit operator T()const
+ {
+ return this->template convert_to<T>();
+ }
+ explicit operator bool()const
+ {
+ using default_ops::eval_is_zero;
+ return !eval_is_zero(backend());
+ }
+#endif
#endif
//
// Default precision:
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk