Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82604 - trunk/boost/multiprecision
From: john_at_[hidden]
Date: 2013-01-25 07:49:55


Author: johnmaddock
Date: 2013-01-25 07:49:55 EST (Fri, 25 Jan 2013)
New Revision: 82604
URL: http://svn.boost.org/trac/boost/changeset/82604

Log:
Fix gcc build failures and warnings
Text files modified:
   trunk/boost/multiprecision/debug_adaptor.hpp | 3 +
   trunk/boost/multiprecision/logged_adaptor.hpp | 9 ++--
   trunk/boost/multiprecision/mpfr.hpp | 78 ++++++++++++++++++++++++++++++++-------
   3 files changed, 71 insertions(+), 19 deletions(-)

Modified: trunk/boost/multiprecision/debug_adaptor.hpp
==============================================================================
--- trunk/boost/multiprecision/debug_adaptor.hpp (original)
+++ trunk/boost/multiprecision/debug_adaptor.hpp 2013-01-25 07:49:55 EST (Fri, 25 Jan 2013)
@@ -7,6 +7,7 @@
 #define BOOST_MATH_DEBUG_ADAPTER_HPP
 
 #include <boost/multiprecision/traits/extract_exponent_type.hpp>
+#include <boost/multiprecision/detail/integer_ops.hpp>
 
 namespace boost{
 namespace multiprecision{
@@ -412,7 +413,7 @@
 namespace std{
 
 template <class Backend, boost::multiprecision::expression_template_option ExpressionTemplates>
-class numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<Backend>, ExpressionTemplates> >
+class numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<Backend>, ExpressionTemplates> >
    : public std::numeric_limits<boost::multiprecision::number<Backend, ExpressionTemplates> >
 {
    typedef std::numeric_limits<boost::multiprecision::number<Backend, ExpressionTemplates> > base_type;

Modified: trunk/boost/multiprecision/logged_adaptor.hpp
==============================================================================
--- trunk/boost/multiprecision/logged_adaptor.hpp (original)
+++ trunk/boost/multiprecision/logged_adaptor.hpp 2013-01-25 07:49:55 EST (Fri, 25 Jan 2013)
@@ -7,6 +7,7 @@
 #define BOOST_MATH_LOGGED_ADAPTER_HPP
 
 #include <boost/multiprecision/traits/extract_exponent_type.hpp>
+#include <boost/multiprecision/detail/integer_ops.hpp>
 
 namespace boost{
 namespace multiprecision{
@@ -398,7 +399,7 @@
    using default_ops::eval_bit_set;
    log_prefix_event(arg.value(), a, "bit-set");
    eval_bit_set(arg.value(), a);
- log_postfix_event(arg.value(), r, "bit-set");
+ log_postfix_event(arg.value(), arg, "bit-set");
 }
 template <class Backend>
 inline void eval_bit_unset(const logged_adaptor<Backend>& arg, unsigned a)
@@ -406,7 +407,7 @@
    using default_ops::eval_bit_unset;
    log_prefix_event(arg.value(), a, "bit-unset");
    eval_bit_unset(arg.value(), a);
- log_postfix_event(arg.value(), r, "bit-unset");
+ log_postfix_event(arg.value(), arg, "bit-unset");
 }
 template <class Backend>
 inline void eval_bit_flip(const logged_adaptor<Backend>& arg, unsigned a)
@@ -414,7 +415,7 @@
    using default_ops::eval_bit_flip;
    log_prefix_event(arg.value(), a, "bit-flip");
    eval_bit_flip(arg.value(), a);
- log_postfix_event(arg.value(), r, "bit-flip");
+ log_postfix_event(arg.value(), arg, "bit-flip");
 }
 
 NON_MEMBER_OP3(gcd, "gcd");
@@ -466,7 +467,7 @@
 namespace std{
 
 template <class Backend, boost::multiprecision::expression_template_option ExpressionTemplates>
-class numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<Backend>, ExpressionTemplates> >
+class numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<Backend>, ExpressionTemplates> >
    : public std::numeric_limits<boost::multiprecision::number<Backend, ExpressionTemplates> >
 {
    typedef std::numeric_limits<boost::multiprecision::number<Backend, ExpressionTemplates> > base_type;

Modified: trunk/boost/multiprecision/mpfr.hpp
==============================================================================
--- trunk/boost/multiprecision/mpfr.hpp (original)
+++ trunk/boost/multiprecision/mpfr.hpp 2013-01-25 07:49:55 EST (Fri, 25 Jan 2013)
@@ -1246,14 +1246,14 @@
 #endif
 
 template <unsigned Digits10, mpfr_allocation_type AllocateType, class Integer>
-inline typename enable_if<mpl::and_<is_signed<Integer>, mpl::bool_<BOOST_MP_ENABLE_IF_WORKAROUND (sizeof(Integer) <= sizeof(long))> > >::type
+inline typename enable_if<mpl::and_<is_signed<Integer>, mpl::bool_<BOOST_MP_ENABLE_IF_WORKAROUND (sizeof(Integer) <= sizeof(long))> > >::type
    eval_pow(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& b, const Integer& e)
 {
    mpfr_pow_si(result.data(), b.data(), e, GMP_RNDN);
 }
 
 template <unsigned Digits10, mpfr_allocation_type AllocateType, class Integer>
-inline typename enable_if<mpl::and_<is_unsigned<Integer>, mpl::bool_<BOOST_MP_ENABLE_IF_WORKAROUND (sizeof(Integer) <= sizeof(long))> > >::type
+inline typename enable_if<mpl::and_<is_unsigned<Integer>, mpl::bool_<BOOST_MP_ENABLE_IF_WORKAROUND (sizeof(Integer) <= sizeof(long))> > >::type
    eval_pow(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& b, const Integer& e)
 {
    mpfr_pow_ui(result.data(), b.data(), e, GMP_RNDN);
@@ -1392,15 +1392,47 @@
 template <class T> struct constant_euler;
 template <class T> struct constant_catalan;
 
+namespace detail{
+
+ template <class T, int N>
+ struct mpfr_constant_initializer
+ {
+ static void force_instantiate()
+ {
+ init.force_instantiate();
+ }
+ private:
+ struct initializer
+ {
+ initializer()
+ {
+ T::get(mpl::int_<N>());
+ }
+ void force_instantiate()const{}
+ };
+ static const initializer init;
+ };
+
+ template <class T, int N>
+ typename mpfr_constant_initializer<T, N>::initializer const mpfr_constant_initializer<T, N>::init;
+
+}
+
 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
 struct constant_pi<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
 {
    typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
    template<int N>
- static inline result_type get(const mpl::int_<N>&)
+ static inline const result_type& get(const mpl::int_<N>&)
    {
- result_type result;
- mpfr_const_pi(result.backend().data(), GMP_RNDN);
+ detail::mpfr_constant_initializer<constant_pi<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
+ static result_type result;
+ static bool has_init = false;
+ if(!has_init)
+ {
+ mpfr_const_pi(result.backend().data(), GMP_RNDN);
+ has_init = true;
+ }
       return result;
    }
 };
@@ -1409,10 +1441,16 @@
 {
    typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
    template<int N>
- static inline result_type get(const mpl::int_<N>&)
+ static inline const result_type& get(const mpl::int_<N>&)
    {
- result_type result;
- mpfr_const_log2(result.backend().data(), GMP_RNDN);
+ detail::mpfr_constant_initializer<constant_ln_two<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
+ static result_type result;
+ static bool init = false;
+ if(!init)
+ {
+ mpfr_const_log2(result.backend().data(), GMP_RNDN);
+ init = true;
+ }
       return result;
    }
 };
@@ -1421,10 +1459,16 @@
 {
    typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
    template<int N>
- static inline result_type get(const mpl::int_<N>&)
+ static inline const result_type& get(const mpl::int_<N>&)
    {
- result_type result;
- mpfr_const_euler(result.backend().data(), GMP_RNDN);
+ detail::mpfr_constant_initializer<constant_euler<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
+ static result_type result;
+ static bool init = false;
+ if(!init)
+ {
+ mpfr_const_euler(result.backend().data(), GMP_RNDN);
+ init = true;
+ }
       return result;
    }
 };
@@ -1433,10 +1477,16 @@
 {
    typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
    template<int N>
- static inline result_type get(const mpl::int_<N>&)
+ static inline const result_type& get(const mpl::int_<N>&)
    {
- result_type result;
- mpfr_const_catalan(result.backend().data(), GMP_RNDN);
+ detail::mpfr_constant_initializer<constant_catalan<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
+ static result_type result;
+ static bool init = false;
+ if(!init)
+ {
+ mpfr_const_catalan(result.backend().data(), GMP_RNDN);
+ init = true;
+ }
       return result;
    }
 };


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