Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82461 - trunk/boost/math/constants
From: john_at_[hidden]
Date: 2013-01-12 06:10:12


Author: johnmaddock
Date: 2013-01-12 06:10:11 EST (Sat, 12 Jan 2013)
New Revision: 82461
URL: http://svn.boost.org/trac/boost/changeset/82461

Log:
Enable caching of arbitrary precision constants.
Text files modified:
   trunk/boost/math/constants/constants.hpp | 9 +++++++--
   1 files changed, 7 insertions(+), 2 deletions(-)

Modified: trunk/boost/math/constants/constants.hpp
==============================================================================
--- trunk/boost/math/constants/constants.hpp (original)
+++ trunk/boost/math/constants/constants.hpp 2013-01-12 06:10:11 EST (Sat, 12 Jan 2013)
@@ -170,6 +170,11 @@
    }\
    /* This one is for very high precision that is none the less known at compile time: */ \
    template <int N> static T compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>));\
+ template <int N> static inline T get_from_compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))\
+ {\
+ static const T result = compute<N>();\
+ return result;\
+ }\
    /* public getters come next */\
    public:\
    static inline T get(const mpl::int_<construct_from_string>&)\
@@ -185,8 +190,8 @@
    { return BOOST_JOIN(x, L); }\
    template <int N> static inline T get(const mpl::int_<N>& n)\
    {\
- constant_initializer2<T, N, & BOOST_JOIN(constant_, name)<T>::template compute<N> >::force_instantiate();\
- return compute<N>(); \
+ constant_initializer2<T, N, & BOOST_JOIN(constant_, name)<T>::template get_from_compute<N> >::force_instantiate();\
+ return get_from_compute<N>(); \
    }\
    /* This one is for true arbitary precision, which may well vary at runtime: */ \
    static inline T get(const mpl::int_<0>&)\


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