Skip to content

Commit 31f87e3

Browse files
committed
Add typedef to each type
1 parent 00bc47f commit 31f87e3

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

include/boost/decimal/decimal128.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ struct decimal128_components
142142

143143
BOOST_DECIMAL_EXPORT class decimal128 final
144144
{
145+
public:
146+
using significand_type = detail::uint128;
147+
145148
private:
146149
detail::uint128 bits_ {};
147150

@@ -575,7 +578,7 @@ BOOST_DECIMAL_EXPORT class decimal128 final
575578

576579
// <cmath> functions that need to be friends
577580
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
578-
friend constexpr auto frexp10(T num, int* expptr) noexcept;
581+
friend constexpr auto frexp10(T num, int* expptr) noexcept -> typename T::significand_type;
579582

580583
friend constexpr auto copysignd128(decimal128 mag, decimal128 sgn) noexcept -> decimal128;
581584
friend constexpr auto scalblnd128(decimal128 num, long exp) noexcept -> decimal128;

include/boost/decimal/decimal32.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ struct decimal32_components
134134
// 3.2.2 class decimal32
135135
BOOST_DECIMAL_EXPORT class decimal32 final // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions)
136136
{
137+
public:
138+
using significand_type = std::uint32_t;
139+
137140
private:
138141

139142
std::uint32_t bits_ {};
@@ -561,7 +564,7 @@ BOOST_DECIMAL_EXPORT class decimal32 final // NOLINT(cppcoreguidelines-special-m
561564

562565
// Related to <cmath>
563566
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
564-
friend constexpr auto frexp10(T num, int* expptr) noexcept;
567+
friend constexpr auto frexp10(T num, int* expptr) noexcept -> typename T::significand_type;
565568

566569
friend constexpr auto scalbnd32(decimal32 num, int exp) noexcept -> decimal32;
567570
friend constexpr auto scalblnd32(decimal32 num, long exp) noexcept -> decimal32;

include/boost/decimal/decimal32_fast.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d32_fast_snan = std::numeric_limits<std::u
2727

2828
class decimal32_fast final
2929
{
30+
public:
31+
using significand_type = std::uint32_t;
32+
3033
private:
3134
// In regular decimal32 we have to decode the 24 bits of the significand and the 8 bits of the exp
3235
// Here we just use them directly at the cost of 2 extra bytes of internal state
@@ -65,7 +68,7 @@ class decimal32_fast final
6568
BOOST_DECIMAL_REQUIRES_TWO_RETURN(detail::is_decimal_floating_point_v, Decimal, detail::is_integral_v, TargetType, TargetType);
6669

6770
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
68-
friend constexpr auto frexp10(T num, int* expptr) noexcept;
71+
friend constexpr auto frexp10(T num, int* expptr) noexcept -> typename T::significand_type;
6972

7073
public:
7174
constexpr decimal32_fast() noexcept : significand_{}, exponent_{}, sign_ {} {}
@@ -138,7 +141,7 @@ class decimal32_fast final
138141
explicit constexpr operator detail::int128_t() const noexcept;
139142
explicit constexpr operator detail::uint128_t() const noexcept;
140143
#endif
141-
144+
142145
friend constexpr auto direct_init(std::uint32_t significand, std::uint8_t exponent, bool sign) noexcept -> decimal32_fast;
143146
};
144147

include/boost/decimal/decimal64.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ struct decimal64_components
132132

133133
BOOST_DECIMAL_EXPORT class decimal64 final
134134
{
135+
public:
136+
using significand_type = std::uint64_t;
137+
135138
private:
136139

137140
std::uint64_t bits_ {};
@@ -563,7 +566,7 @@ BOOST_DECIMAL_EXPORT class decimal64 final
563566

564567
// <cmath> functions that need to be friends
565568
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
566-
friend constexpr auto frexp10(T num, int* expptr) noexcept;
569+
friend constexpr auto frexp10(T num, int* expptr) noexcept -> typename T::significand_type;
567570

568571
friend constexpr auto copysignd64(decimal64 mag, decimal64 sgn) noexcept -> decimal64;
569572
friend constexpr auto fmad64(decimal64 x, decimal64 y, decimal64 z) noexcept -> decimal64;

include/boost/decimal/detail/cmath/frexp10.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ namespace decimal {
2525
//
2626
// If the conversion can not be performed returns UINT32_MAX and exp = 0
2727
BOOST_DECIMAL_EXPORT template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
28-
constexpr auto frexp10(T num, int* expptr) noexcept
28+
constexpr auto frexp10(T num, int* expptr) noexcept -> typename T::significand_type
2929
{
30-
using ReturnType = std::conditional_t<std::is_same<T, decimal32>::value || std::is_same<T, decimal32_fast>::value, std::uint32_t,
31-
std::conditional_t<std::is_same<T, decimal64>::value, std::uint64_t, detail::uint128>>;
30+
using ReturnType = typename T::significand_type;
3231

3332
constexpr T zero {0, 0};
3433

include/boost/decimal/detail/comparison.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE DecimalType = decimal32, typename
2626
constexpr auto equal_parts_impl(T1 lhs_sig, std::int32_t lhs_exp, bool lhs_sign,
2727
T2 rhs_sig, std::int32_t rhs_exp, bool rhs_sign) noexcept -> bool
2828
{
29-
using sig_type = std::conditional_t<std::is_same<DecimalType, decimal32>::value || std::is_same<DecimalType, decimal32_fast>::value, std::uint32_t,
30-
std::conditional_t<std::is_same<DecimalType, decimal64>::value, std::uint64_t , detail::uint128>>;
29+
using sig_type = typename DecimalType::significand_type;
3130

3231
auto new_lhs_sig {detail::shrink_significand<sig_type>(lhs_sig, lhs_exp)};
3332
auto new_rhs_sig {detail::shrink_significand<sig_type>(rhs_sig, rhs_exp)};
@@ -114,8 +113,7 @@ constexpr auto less_parts_impl(T1 lhs_sig, std::int32_t lhs_exp, bool lhs_sign,
114113
const bool both_neg {lhs_sign && rhs_sign};
115114

116115
// Normalize the significands and exponents
117-
using sig_type = std::conditional_t<std::is_same<DecimalType, decimal32>::value || std::is_same<DecimalType, decimal32_fast>::value, std::uint32_t,
118-
std::conditional_t<std::is_same<DecimalType, decimal64>::value, std::uint64_t , detail::uint128>>;
116+
using sig_type = typename DecimalType::significand_type;
119117

120118
auto new_lhs_sig {detail::shrink_significand<sig_type>(lhs_sig, lhs_exp)};
121119
auto new_rhs_sig {detail::shrink_significand<sig_type>(rhs_sig, rhs_exp)};

0 commit comments

Comments
 (0)