Skip to content

Commit 0c973c9

Browse files
committed
Address review and tune more syntax
1 parent e92330a commit 0c973c9

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

include/boost/math/constants/info.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
#include <boost/math/constants/constants.hpp>
1414
#include <iostream>
1515
#include <iomanip>
16+
#ifndef BOOST_MATH_NO_RTTI
1617
#include <typeinfo>
18+
#endif
1719

1820
namespace boost{ namespace math{ namespace constants{
1921

@@ -22,7 +24,11 @@ namespace boost{ namespace math{ namespace constants{
2224
template <class T>
2325
const char* nameof(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
2426
{
27+
#ifndef BOOST_MATH_NO_RTTI
2528
return typeid(T).name();
29+
#else
30+
return "unknown";
31+
#endif
2632
}
2733
template <>
2834
const char* nameof<float>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(float))

include/boost/math/policies/error_handling.hpp

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,32 @@
88
#ifndef BOOST_MATH_POLICY_ERROR_HANDLING_HPP
99
#define BOOST_MATH_POLICY_ERROR_HANDLING_HPP
1010

11+
#include <boost/math/policies/policy.hpp>
1112
#include <boost/math/tools/config.hpp>
1213
#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>
1714
#include <boost/math/tools/precision.hpp>
15+
#include <boost/math/tools/tuple.hpp>
16+
#include <boost/math/tools/type_traits.hpp>
1817

1918
#ifndef BOOST_MATH_HAS_NVRTC
2019

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>
2622
#endif
23+
2724
#include <cerrno>
28-
#include <complex>
2925
#include <cmath>
26+
#include <complex>
3027
#include <cstdint>
28+
#include <cstring>
29+
#include <iomanip>
30+
#include <sstream>
3131
#ifndef BOOST_MATH_NO_EXCEPTIONS
3232
#include <stdexcept>
33-
#include <boost/math/tools/throw_exception.hpp>
33+
#endif
34+
#include <string>
35+
#ifndef BOOST_MATH_NO_RTTI
36+
#include <typeinfo>
3437
#endif
3538

3639
#ifdef _MSC_VER
@@ -43,7 +46,6 @@
4346
// Note that this only occurs when the compiler can deduce code is unreachable,
4447
// for example when policy macros are used to ignore errors rather than throw.
4548
#endif
46-
#include <sstream>
4749

4850
namespace boost{ namespace math{
4951

@@ -91,15 +93,20 @@ namespace detail
9193
template <class T>
9294
inline std::string prec_format(const T& val)
9395
{
94-
typedef typename boost::math::policies::precision<T, boost::math::policies::policy<> >::type prec_type;
95-
std::stringstream ss;
96-
if(prec_type::value)
96+
using prec_type = typename boost::math::policies::precision<T, boost::math::policies::policy<> >::type;
97+
98+
std::stringstream strm { };
99+
100+
if(prec_type::value != prec_type { 0 })
97101
{
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);
100105
}
101-
ss << val;
102-
return ss.str();
106+
107+
strm << val;
108+
109+
return strm.str();
103110
}
104111

105112
#ifdef BOOST_MATH_USE_CHARCONV_FOR_CONVERSION

include/boost/math/policies/policy.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ namespace policies{
132132

133133
#define BOOST_MATH_META_INT(Type, name, Default) \
134134
template <Type N = Default> \
135-
class name : public boost::math::integral_constant<int, static_cast<int>(N)>{}; \
135+
class name : public boost::math::integral_constant<Type, N> { }; \
136136
\
137137
namespace detail{ \
138138
template <Type N> \

0 commit comments

Comments
 (0)