Skip to content

Commit 4aa7965

Browse files
committed
After egg's review.
1 parent bb64033 commit 4aa7965

5 files changed

Lines changed: 28 additions & 27 deletions

File tree

numerics/elementary_functions_body.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ using namespace principia::quantities::_si;
2929
// `FusedMultiplyAdd` and friends need to exist.
3030
namespace noncritical {
3131

32-
template<cpp_bin_float Q1, cpp_bin_float Q2>
32+
template<boost_cpp_bin_float Q1, boost_cpp_bin_float Q2>
3333
Product<Q1, Q2> FusedMultiplyAdd(Q1 const& x,
3434
Q2 const& y,
3535
Product<Q1, Q2> const& z) {
@@ -43,12 +43,12 @@ Product<Q1, Q2> FusedMultiplyAdd(Q1 const& x,
4343
return x * y + z;
4444
}
4545

46-
template<cpp_number Q>
46+
template<boost_cpp_number Q>
4747
Q Abs(Q const& x) {
4848
return abs(x);
4949
}
5050

51-
template<cpp_number Q>
51+
template<boost_cpp_number Q>
5252
Q Round(Q const& x) {
5353
// TODO(phl): This is clunky. Use `divide_qr` or something.
5454
return static_cast<Q>(round(static_cast<cpp_bin_float_50>(x)));

numerics/polynomial_in_monomial_basis_body.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ namespace numerics {
2525
namespace _polynomial_in_monomial_basis {
2626
namespace internal {
2727

28-
using namespace boost::multiprecision;
2928
using namespace principia::base::_not_constructible;
3029
using namespace principia::geometry::_cartesian_product;
3130
using namespace principia::geometry::_serialization;
@@ -519,7 +518,7 @@ template<typename Value_, typename Argument_, int degree_>
519518
void PolynomialInMonomialBasis<Value_, Argument_, degree_>::
520519
WriteToMessage(not_null<serialization::Polynomial*> message) const {
521520
// No serialization for Boost types.
522-
if constexpr (!cpp_number<Value>) {
521+
if constexpr (!boost_cpp_number<Value>) {
523522
message->set_degree(degree_);
524523
auto* const extension = message->MutableExtension(
525524
serialization::PolynomialInMonomialBasis::extension);

quantities/cantor.hpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,44 @@ namespace internal {
1313
using namespace boost::multiprecision;
1414
using namespace principia::base::_traits;
1515

16-
// The `cpp_` concepts should be used sparingly, and only in places where the
17-
// Boost multiprecision API differs from ours or from the standard C++ API. At
18-
// any rate, the multiprecision traits should never be used directly.
16+
// The `boost_cpp_` concepts should be used sparingly, and only in places where
17+
// the Boost multiprecision API differs from ours or from the standard C++ API.
18+
// At any rate, the multiprecision traits should never be used directly.
1919

2020
template<typename T>
21-
concept cpp_number = (is_number<T>::value || is_number_expression<T>::value) &&
21+
concept boost_cpp_number = (is_number<T>::value || is_number_expression<T>::value) &&
2222
number_category<T>::value != number_kind_unknown;
2323

2424
template<typename T>
25-
concept cpp_bin_float =
26-
cpp_number<T> && number_category<T>::value == number_kind_floating_point;
25+
concept boost_cpp_bin_float =
26+
boost_cpp_number<T> && number_category<T>::value == number_kind_floating_point;
2727

2828
template<typename T>
29-
concept cpp_int =
30-
cpp_number<T> && number_category<T>::value == number_kind_integer;
29+
concept boost_cpp_int =
30+
boost_cpp_number<T> && number_category<T>::value == number_kind_integer;
3131

3232
template<typename T>
33-
concept cpp_rational =
34-
cpp_number<T> && number_category<T>::value == number_kind_rational;
33+
concept boost_cpp_rational =
34+
boost_cpp_number<T> && number_category<T>::value == number_kind_rational;
3535

3636

3737
template<typename T>
38-
concept discrete = std::integral<T> || cpp_int<T>;
38+
concept discrete = std::integral<T> || boost_cpp_int<T>;
3939

4040
template<typename T>
41-
concept countable = discrete<T> || cpp_rational<T>;
41+
concept countable = discrete<T> || boost_cpp_rational<T>;
4242

4343
template<typename T>
44-
concept continuum = std::floating_point<T> || cpp_bin_float<T>;
44+
concept continuum = std::floating_point<T> || boost_cpp_bin_float<T>;
4545

4646
} // namespace internal
4747

48-
// `cpp_int` and `cpp_rational` are not exported on purpose.
48+
using internal::boost_cpp_bin_float;
49+
using internal::boost_cpp_int;
50+
using internal::boost_cpp_number;
51+
using internal::boost_cpp_rational;
4952
using internal::continuum;
5053
using internal::countable;
51-
using internal::cpp_bin_float;
52-
using internal::cpp_number;
5354
using internal::discrete;
5455

5556
} // namespace _cantor

quantities/quantities.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,11 @@ __m128d ToM128D(Quantity<Dimensions> x);
144144
template<typename Q>
145145
constexpr Q Infinity = SIUnit<Q>() * std::numeric_limits<double>::infinity();
146146

147-
// A quiet NaN of `Q`. Note that NaN for `cpp_number` cannot be constexpr.
147+
// A quiet NaN of `Q`. Note that NaN for `boost_cpp_number` cannot be
148+
// constexpr.
148149
template <typename Q>
149150
CONSTEXPR_NAN Q NaN = SIUnit<Q>() * std::numeric_limits<double>::quiet_NaN();
150-
template<cpp_number Q>
151+
template<boost_cpp_number Q>
151152
Q NaN<Q> = std::numeric_limits<Q>::quiet_NaN();
152153

153154
template<typename Q>
@@ -164,7 +165,7 @@ template<typename D>
164165
std::string DebugString(
165166
Quantity<D> const& quantity,
166167
int precision = std::numeric_limits<double>::max_digits10);
167-
template<cpp_number N>
168+
template<boost_cpp_number N>
168169
std::string DebugString(
169170
N const& number,
170171
int precision = std::numeric_limits<double>::max_digits10);

quantities/quantities_body.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ inline constexpr double Pow<3>(double x) {
171171

172172
template<int exponent, typename Q>
173173
constexpr Exponentiation<Q, exponent> Pow(Q const& x) {
174-
if constexpr (number_category<Q>::value == number_kind_rational) {
174+
if constexpr (boost_cpp_rational<Q>) {
175175
// It seems that Boost does not define `pow` for `cpp_rational`.
176176
return cpp_rational(pow(numerator(x), exponent),
177177
pow(denominator(x), exponent));
178-
} else if constexpr (is_number<Q>::value) {
178+
} else if constexpr (boost_cpp_number<Q>) {
179179
return pow(x, exponent);
180180
} else {
181181
return SIUnit<Exponentiation<Q, exponent>>() *
@@ -243,7 +243,7 @@ std::string DebugString(Quantity<D> const& quantity, int const precision) {
243243
Format<D>();
244244
}
245245

246-
template<cpp_number N>
246+
template<boost_cpp_number N>
247247
std::string DebugString(N const& number, int const precision) {
248248
return number.str();
249249
}

0 commit comments

Comments
 (0)