@@ -20,149 +20,162 @@ namespace decimal {
2020# pragma GCC diagnostic ignored "-Wconversion"
2121#endif
2222
23- BOOST_DECIMAL_CXX20_CONSTEXPR auto to_bid_d32 (decimal32 val) noexcept -> std::uint32_t
23+ constexpr auto to_bid_d32 (decimal32 val) noexcept -> std::uint32_t
2424{
25- const auto bits {detail::bit_cast<std::uint32_t >(val)};
26- return bits;
25+ return val.bits_ ;
2726}
2827
29- BOOST_DECIMAL_CXX20_CONSTEXPR auto from_bid_d32 (std::uint32_t bits) noexcept -> decimal32
28+ constexpr auto from_bid_d32 (std::uint32_t bits) noexcept -> decimal32
3029{
31- const auto val {detail::bit_cast<decimal32>(bits)};
32- return val;
30+ return from_bits (bits);
3331}
3432
35- BOOST_DECIMAL_CXX20_CONSTEXPR auto to_bid_d32f (decimal32_fast val) noexcept -> std::uint32_t
33+ constexpr auto to_bid_d32f (decimal32_fast val) noexcept -> std::uint32_t
3634{
3735 const decimal32 compliant_val {val};
38- const auto bits {detail::bit_cast<std::uint32_t >(compliant_val)};
39- return bits;
36+ return to_bid_d32 (compliant_val);
4037}
4138
42- BOOST_DECIMAL_CXX20_CONSTEXPR auto from_bid_d32f (std::uint32_t bits) noexcept -> decimal32_fast
39+ constexpr auto from_bid_d32f (std::uint32_t bits) noexcept -> decimal32_fast
4340{
44- const auto compliant_val {detail::bit_cast<decimal32> (bits)};
41+ const auto compliant_val {from_bid_d32 (bits)};
4542 const decimal32_fast val {compliant_val};
4643 return val;
4744}
4845
49- BOOST_DECIMAL_CXX20_CONSTEXPR auto to_bid_d64 (decimal64 val) noexcept -> std::uint64_t
46+ constexpr auto to_bid_d64 (decimal64 val) noexcept -> std::uint64_t
5047{
51- const auto bits {detail::bit_cast<std::uint64_t >(val)};
52- return bits;
48+ return val.bits_ ;
5349}
5450
55- BOOST_DECIMAL_CXX20_CONSTEXPR auto from_bid_d64 (std::uint64_t bits) noexcept -> decimal64
51+ constexpr auto from_bid_d64 (std::uint64_t bits) noexcept -> decimal64
5652{
57- const auto val {detail::bit_cast<decimal64>(bits)};
58- return val;
53+ return from_bits (bits);
5954}
6055
61- BOOST_DECIMAL_CXX20_CONSTEXPR auto to_bid_d64f (decimal64_fast val) noexcept -> std::uint64_t
56+ constexpr auto to_bid_d64f (decimal64_fast val) noexcept -> std::uint64_t
6257{
6358 const decimal64 compliant_val {val};
64- const auto bits {detail::bit_cast<std::uint64_t >(compliant_val)};
65- return bits;
59+ return to_bid_d64 (compliant_val);
6660}
6761
68- BOOST_DECIMAL_CXX20_CONSTEXPR auto from_bid_d64f (std::uint64_t bits) noexcept -> decimal64_fast
62+ constexpr auto from_bid_d64f (std::uint64_t bits) noexcept -> decimal64_fast
6963{
70- const auto compliant_val {detail::bit_cast<decimal64> (bits)};
64+ const auto compliant_val {from_bid_d64 (bits)};
7165 const decimal64_fast val {compliant_val};
7266 return val;
7367}
7468
75- BOOST_DECIMAL_CXX20_CONSTEXPR auto to_bid_d128 (decimal128 val) noexcept -> detail::uint128
69+ constexpr auto to_bid_d128 (decimal128 val) noexcept -> detail::uint128
7670{
77- const auto bits {detail::bit_cast<detail::uint128>(val)};
78- return bits;
71+ return val.bits_ ;
7972}
8073
81- BOOST_DECIMAL_CXX20_CONSTEXPR auto from_bid_d128 (detail::uint128 bits) noexcept -> decimal128
74+ constexpr auto from_bid_d128 (detail::uint128 bits) noexcept -> decimal128
8275{
83- const auto val {detail::bit_cast<decimal128>(bits)};
84- return val;
76+ return from_bits (bits);
77+ }
78+
79+ #ifdef BOOST_DECIMAL_HAS_INT128
80+ constexpr auto from_bits_d128 (detail::uint128_t bits) noexcept -> decimal128
81+ {
82+ return from_bits (bits);
8583}
84+ #endif
8685
87- BOOST_DECIMAL_CXX20_CONSTEXPR auto to_bid_d128f (decimal128_fast val) noexcept -> detail::uint128
86+ constexpr auto to_bid_d128f (decimal128_fast val) noexcept -> detail::uint128
8887{
8988 const decimal128 compliant_val {val};
90- const auto bits {detail::bit_cast<detail::uint128>(compliant_val)};
91- return bits;
89+ return to_bid_d128 (compliant_val);
90+ }
91+
92+ constexpr auto from_bid_d128f (detail::uint128 bits) noexcept -> decimal128_fast
93+ {
94+ const auto compliant_val {from_bid_d128 (bits)};
95+ const decimal128_fast val {compliant_val};
96+ return val;
9297}
9398
94- BOOST_DECIMAL_CXX20_CONSTEXPR auto from_bid_d128f (detail::uint128 bits) noexcept -> decimal128_fast
99+ #ifdef BOOST_DECIMAL_HAS_INT128
100+ constexpr auto from_bid_d128f (detail::uint128_t bits) noexcept -> decimal128_fast
95101{
96- const auto compliant_val {detail::bit_cast<decimal128> (bits)};
102+ const auto compliant_val {from_bid_d128 (bits)};
97103 const decimal128_fast val {compliant_val};
98104 return val;
99105}
106+ #endif
100107
101- BOOST_DECIMAL_CXX20_CONSTEXPR auto to_bid (decimal32 val) noexcept -> std::uint32_t
108+ constexpr auto to_bid (decimal32 val) noexcept -> std::uint32_t
102109{
103110 return to_bid_d32 (val);
104111}
105112
106- BOOST_DECIMAL_CXX20_CONSTEXPR auto to_bid (decimal32_fast val) noexcept -> std::uint32_t
113+ constexpr auto to_bid (decimal32_fast val) noexcept -> std::uint32_t
107114{
108115 return to_bid_d32f (val);
109116}
110117
111- BOOST_DECIMAL_CXX20_CONSTEXPR auto to_bid (decimal64 val) noexcept -> std::uint64_t
118+ constexpr auto to_bid (decimal64 val) noexcept -> std::uint64_t
112119{
113120 return to_bid_d64 (val);
114121}
115122
116- BOOST_DECIMAL_CXX20_CONSTEXPR auto to_bid (decimal64_fast val) noexcept -> std::uint64_t
123+ constexpr auto to_bid (decimal64_fast val) noexcept -> std::uint64_t
117124{
118125 return to_bid_d64f (val);
119126}
120127
121- BOOST_DECIMAL_CXX20_CONSTEXPR auto to_bid (decimal128 val) noexcept -> detail::uint128
128+ constexpr auto to_bid (decimal128 val) noexcept -> detail::uint128
122129{
123130 return to_bid_d128 (val);
124131}
125132
126- BOOST_DECIMAL_CXX20_CONSTEXPR auto to_bid (decimal128_fast val) noexcept -> detail::uint128
133+ constexpr auto to_bid (decimal128_fast val) noexcept -> detail::uint128
127134{
128135 return to_bid_d128f (val);
129136}
130137
138+ template <typename T>
139+ constexpr auto to_bid (T val) noexcept
140+ {
141+ return to_bid (val);
142+ }
143+
131144template <typename T = decimal32_fast>
132- BOOST_DECIMAL_CXX20_CONSTEXPR auto from_bid (std::uint32_t bits) noexcept
145+ constexpr auto from_bid (std::uint32_t bits) noexcept
133146 BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
134147{
135148 return from_bid_d32f (bits);
136149}
137150
138151template <>
139- BOOST_DECIMAL_CXX20_CONSTEXPR auto from_bid<decimal32>(std::uint32_t bits) noexcept -> decimal32
152+ constexpr auto from_bid<decimal32>(std::uint32_t bits) noexcept -> decimal32
140153{
141154 return from_bid_d32 (bits);
142155}
143156
144157template <typename T = decimal64_fast>
145- BOOST_DECIMAL_CXX20_CONSTEXPR auto from_bid (std::uint64_t bits) noexcept
158+ constexpr auto from_bid (std::uint64_t bits) noexcept
146159 BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
147160{
148161 return from_bid_d64f (bits);
149162}
150163
151164template <>
152- BOOST_DECIMAL_CXX20_CONSTEXPR auto from_bid<decimal64>(std::uint64_t bits) noexcept -> decimal64
165+ constexpr auto from_bid<decimal64>(std::uint64_t bits) noexcept -> decimal64
153166{
154167 return from_bid_d64 (bits);
155168}
156169
157170template <typename T = decimal128_fast>
158- BOOST_DECIMAL_CXX20_CONSTEXPR auto from_bid (detail::uint128 bits) noexcept
171+ constexpr auto from_bid (detail::uint128 bits) noexcept
159172 BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
160173{
161174 return from_bid_d128f (bits);
162175}
163176
164177template <>
165- BOOST_DECIMAL_CXX20_CONSTEXPR auto from_bid<decimal128>(detail::uint128 bits) noexcept -> decimal128
178+ constexpr auto from_bid<decimal128>(detail::uint128 bits) noexcept -> decimal128
166179{
167180 return from_bid_d128 (bits);
168181}
0 commit comments