Skip to content

Commit 3a3c645

Browse files
committed
converted formafractional_part_rounding_thresholds to use an array of u32s instead of a unicode literal character array for compatibliity with CUDA and non CUDA platforms
1 parent 4968433 commit 3a3c645

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

include/fmt/format.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3208,15 +3208,22 @@ FMT_CONSTEXPR20 void format_hexfloat(Float value, format_specs specs,
32083208
format_hexfloat(static_cast<double>(value), specs, buf);
32093209
}
32103210

3211+
// pre C++23 does not allow static constexpr inside of constexpr functions
3212+
// so we must declare this outside of fractional_part_rounding_thresholds
3213+
static constexpr uint32_t utf8_raw_rounding_thresholds[8] = {
3214+
0x9999999au, 0x828f5c29u, 0x80418938u, 0x80068db9,
3215+
0x8000a7c6u, 0x800010c7u, 0x800001aeu, 0x8000002bu
3216+
};
3217+
32113218
constexpr auto fractional_part_rounding_thresholds(int index) -> uint32_t {
32123219
// For checking rounding thresholds.
32133220
// The kth entry is chosen to be the smallest integer such that the
32143221
// upper 32-bits of 10^(k+1) times it is strictly bigger than 5 * 10^k.
32153222
// It is equal to ceil(2^31 + 2^32/10^(k + 1)).
32163223
// These are stored in a string literal because we cannot have static arrays
32173224
// in constexpr functions and non-static ones are poorly optimized.
3218-
return U"\x9999999a\x828f5c29\x80418938\x80068db9\x8000a7c6\x800010c7"
3219-
U"\x800001ae\x8000002b"[index];
3225+
3226+
return utf8_raw_rounding_thresholds[index];
32203227
}
32213228

32223229
template <typename Float>

0 commit comments

Comments
 (0)