|
8 | 8 | #ifndef BOOST_MATH_POLICY_ERROR_HANDLING_HPP |
9 | 9 | #define BOOST_MATH_POLICY_ERROR_HANDLING_HPP |
10 | 10 |
|
| 11 | +#include <boost/math/policies/policy.hpp> |
11 | 12 | #include <boost/math/tools/config.hpp> |
12 | 13 | #include <boost/math/tools/numeric_limits.hpp> |
13 | | -#include <boost/math/tools/type_traits.hpp> |
14 | | -#include <boost/math/tools/cstdint.hpp> |
15 | | -#include <boost/math/tools/tuple.hpp> |
16 | | -#include <boost/math/policies/policy.hpp> |
17 | 14 | #include <boost/math/tools/precision.hpp> |
| 15 | +#include <boost/math/tools/tuple.hpp> |
| 16 | +#include <boost/math/tools/type_traits.hpp> |
18 | 17 |
|
19 | 18 | #ifndef BOOST_MATH_HAS_NVRTC |
20 | 19 |
|
21 | | -#include <iomanip> |
22 | | -#include <string> |
23 | | -#include <cstring> |
24 | | -#ifndef BOOST_MATH_NO_RTTI |
25 | | -#include <typeinfo> |
| 20 | +#ifndef BOOST_MATH_NO_EXCEPTIONS |
| 21 | +#include <boost/math/tools/throw_exception.hpp> |
26 | 22 | #endif |
| 23 | + |
27 | 24 | #include <cerrno> |
28 | | -#include <complex> |
29 | 25 | #include <cmath> |
| 26 | +#include <complex> |
30 | 27 | #include <cstdint> |
| 28 | +#include <cstring> |
| 29 | +#include <iomanip> |
| 30 | +#include <sstream> |
31 | 31 | #ifndef BOOST_MATH_NO_EXCEPTIONS |
32 | 32 | #include <stdexcept> |
33 | | -#include <boost/math/tools/throw_exception.hpp> |
| 33 | +#endif |
| 34 | +#include <string> |
| 35 | +#ifndef BOOST_MATH_NO_RTTI |
| 36 | +#include <typeinfo> |
34 | 37 | #endif |
35 | 38 |
|
36 | 39 | #ifdef _MSC_VER |
|
43 | 46 | // Note that this only occurs when the compiler can deduce code is unreachable, |
44 | 47 | // for example when policy macros are used to ignore errors rather than throw. |
45 | 48 | #endif |
46 | | -#include <sstream> |
47 | 49 |
|
48 | 50 | namespace boost{ namespace math{ |
49 | 51 |
|
@@ -91,15 +93,20 @@ namespace detail |
91 | 93 | template <class T> |
92 | 94 | inline std::string prec_format(const T& val) |
93 | 95 | { |
94 | | - typedef typename boost::math::policies::precision<T, boost::math::policies::policy<> >::type prec_type; |
95 | | - std::stringstream ss; |
| 96 | + using prec_type = typename boost::math::policies::precision<T, boost::math::policies::policy<> >::type; |
| 97 | + |
| 98 | + std::stringstream strm { }; |
| 99 | + |
96 | 100 | if(prec_type::value) |
97 | 101 | { |
98 | | - int prec = 2 + (prec_type::value * 30103UL) / 100000UL; |
99 | | - ss << std::setprecision(prec); |
| 102 | + const std::streamsize prec { static_cast<std::streamsize>(2UL + (prec_type::value * 30103UL) / 100000UL) }; |
| 103 | + |
| 104 | + strm << std::setprecision(prec); |
100 | 105 | } |
101 | | - ss << val; |
102 | | - return ss.str(); |
| 106 | + |
| 107 | + strm << val; |
| 108 | + |
| 109 | + return strm.str(); |
103 | 110 | } |
104 | 111 |
|
105 | 112 | #ifdef BOOST_MATH_USE_CHARCONV_FOR_CONVERSION |
|
0 commit comments