Skip to content

Commit a247e2d

Browse files
committed
Fix dispatch on type
1 parent 9236b84 commit a247e2d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

include/boost/decimal/detail/to_chars_integer_impl.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ constexpr char* decompose32(std::uint32_t value, char* buffer) noexcept
151151
# pragma warning(disable: 4127 4146)
152152
#endif
153153

154-
template <typename Integer>
154+
template <typename Integer, std::enable_if_t<sizeof(Integer) != 16, bool> = true>
155155
constexpr to_chars_result to_chars_integer_impl(char* first, char* last, Integer value) noexcept
156156
{
157157
using Unsigned_Integer = make_unsigned_t<Integer>;
@@ -279,9 +279,11 @@ constexpr to_chars_result to_chars_integer_impl(char* first, char* last, Integer
279279
return {first + converted_value_digits, std::errc()};
280280
}
281281

282-
template <typename Integer, typename Unsigned_Integer = boost::int128::uint128_t>
283-
constexpr to_chars_result to_chars_128integer_impl(char* first, char* last, Integer value) noexcept
282+
template <typename Integer, std::enable_if_t<sizeof(Integer) == 16, bool> = true>
283+
constexpr to_chars_result to_chars_integer_impl(char* first, char* last, Integer value) noexcept
284284
{
285+
using Unsigned_Integer = boost::int128::uint128_t;
286+
285287
Unsigned_Integer unsigned_value {};
286288

287289
const std::ptrdiff_t user_buffer_size = last - first;
@@ -295,11 +297,11 @@ constexpr to_chars_result to_chars_128integer_impl(char* first, char* last, Inte
295297
// Strip the sign from the value and apply at the end after parsing if the type is signed
296298
BOOST_DECIMAL_IF_CONSTEXPR (std::numeric_limits<Integer>::is_signed
297299
#ifdef BOOST_DECIMAL_HAS_INT128
298-
|| std::is_same<boost::decimal::detail::builtin_uint128_t, Integer>::value
300+
|| std::is_same<boost::decimal::detail::builtin_int128_t, Integer>::value
299301
#endif
300302
)
301303
{
302-
if (value < 0)
304+
if (value < 0U)
303305
{
304306
is_negative = true;
305307
unsigned_value = -(static_cast<Unsigned_Integer>(value));
@@ -339,7 +341,7 @@ constexpr to_chars_result to_chars_128integer_impl(char* first, char* last, Inte
339341
int num_chars[5] {};
340342
int i = 0;
341343

342-
while (converted_value != 0)
344+
while (converted_value != 0U)
343345
{
344346
auto digits = static_cast<std::uint32_t>(converted_value % ten_9);
345347
num_chars[i] = num_digits(digits);

0 commit comments

Comments
 (0)