Skip to content

Commit f51da45

Browse files
authored
Merge pull request #822 from cppalliance/817
Make `uint128` public since we return in a few places to the user
2 parents 088a48f + f7880fe commit f51da45

File tree

5 files changed

+39
-8
lines changed

5 files changed

+39
-8
lines changed

include/boost/decimal/bid_conversion.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <boost/decimal/decimal32_fast.hpp>
1212
#include <boost/decimal/decimal64_fast.hpp>
1313
#include <boost/decimal/decimal128_fast.hpp>
14+
#include <boost/decimal/uint128.hpp>
1415
#include <boost/decimal/detail/concepts.hpp>
1516

1617
namespace boost {
@@ -67,12 +68,12 @@ BOOST_DECIMAL_EXPORT constexpr auto from_bid_d64f(std::uint64_t bits) noexcept -
6768
return val;
6869
}
6970

70-
BOOST_DECIMAL_EXPORT constexpr auto to_bid_d128(decimal128 val) noexcept -> detail::uint128
71+
BOOST_DECIMAL_EXPORT constexpr auto to_bid_d128(decimal128 val) noexcept -> uint128
7172
{
7273
return val.bits_;
7374
}
7475

75-
BOOST_DECIMAL_EXPORT constexpr auto from_bid_d128(detail::uint128 bits) noexcept -> decimal128
76+
BOOST_DECIMAL_EXPORT constexpr auto from_bid_d128(uint128 bits) noexcept -> decimal128
7677
{
7778
return from_bits(bits);
7879
}
@@ -84,13 +85,13 @@ BOOST_DECIMAL_EXPORT constexpr auto from_bid_d128(detail::uint128_t bits) noexce
8485
}
8586
#endif
8687

87-
BOOST_DECIMAL_EXPORT constexpr auto to_bid_d128f(decimal128_fast val) noexcept -> detail::uint128
88+
BOOST_DECIMAL_EXPORT constexpr auto to_bid_d128f(decimal128_fast val) noexcept -> uint128
8889
{
8990
const decimal128 compliant_val {val};
9091
return to_bid_d128(compliant_val);
9192
}
9293

93-
BOOST_DECIMAL_EXPORT constexpr auto from_bid_d128f(detail::uint128 bits) noexcept -> decimal128_fast
94+
BOOST_DECIMAL_EXPORT constexpr auto from_bid_d128f(uint128 bits) noexcept -> decimal128_fast
9495
{
9596
const auto compliant_val {from_bid_d128(bits)};
9697
const decimal128_fast val {compliant_val};
@@ -126,12 +127,12 @@ BOOST_DECIMAL_EXPORT constexpr auto to_bid(decimal64_fast val) noexcept -> std::
126127
return to_bid_d64f(val);
127128
}
128129

129-
BOOST_DECIMAL_EXPORT constexpr auto to_bid(decimal128 val) noexcept -> detail::uint128
130+
BOOST_DECIMAL_EXPORT constexpr auto to_bid(decimal128 val) noexcept -> uint128
130131
{
131132
return to_bid_d128(val);
132133
}
133134

134-
BOOST_DECIMAL_EXPORT constexpr auto to_bid(decimal128_fast val) noexcept -> detail::uint128
135+
BOOST_DECIMAL_EXPORT constexpr auto to_bid(decimal128_fast val) noexcept -> uint128
135136
{
136137
return to_bid_d128f(val);
137138
}
@@ -169,14 +170,14 @@ constexpr auto from_bid<decimal64>(std::uint64_t bits) noexcept -> decimal64
169170
}
170171

171172
BOOST_DECIMAL_EXPORT template <typename T = decimal128_fast>
172-
constexpr auto from_bid(detail::uint128 bits) noexcept
173+
constexpr auto from_bid(uint128 bits) noexcept
173174
BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
174175
{
175176
return from_bid_d128f(bits);
176177
}
177178

178179
BOOST_DECIMAL_EXPORT template <>
179-
constexpr auto from_bid<decimal128>(detail::uint128 bits) noexcept -> decimal128
180+
constexpr auto from_bid<decimal128>(uint128 bits) noexcept -> decimal128
180181
{
181182
return from_bid_d128(bits);
182183
}

include/boost/decimal/uint128.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2024 Matt Borland
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// https://www.boost.org/LICENSE_1_0.txt
4+
5+
#ifndef BOOST_DECIMAL_UINT128_HPP
6+
#define BOOST_DECIMAL_UINT128_HPP
7+
8+
#include <boost/decimal/detail/emulated128.hpp>
9+
10+
namespace boost {
11+
namespace decimal {
12+
13+
using uint128 = detail::uint128;
14+
15+
} // namespace decimal
16+
} // namespace boost
17+
18+
#endif // BOOST_DECIMAL_UINT128_HPP

test/Jamfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,4 @@ compile compile_tests/iostream_compile.cpp ;
189189
compile compile_tests/literals_compile.cpp ;
190190
compile compile_tests/numbers_compile.cpp ;
191191
compile compile_tests/string_compile.cpp ;
192+
compile compile_tests/uint128.cpp ;

test/compile_tests/uint128.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2025 Matt Borland
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// https://www.boost.org/LICENSE_1_0.txt
4+
5+
#include <boost/decimal/bid_conversion.hpp>
6+
7+
int main()
8+
{
9+
return 0;
10+
}

test/test_big_uints.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ int main()
497497

498498
test_digit_counting<boost::decimal::detail::uint128>();
499499
test_digit_counting<boost::decimal::detail::uint256_t>();
500+
test_digit_counting<boost::decimal::uint128>();
500501

501502
return boost::report_errors();
502503
}

0 commit comments

Comments
 (0)