Skip to content

Commit 7f88291

Browse files
authored
write_floating_seconds: Fall back to ::round (#3343)
On some toolchains, `std::round` is not available. Fixes #3342
1 parent cbc7b8d commit 7f88291

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

include/fmt/chrono.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -1168,10 +1168,13 @@ void write_floating_seconds(memory_buffer& buf, Duration duration,
11681168
auto val = duration.count();
11691169

11701170
if (num_fractional_digits < 0) {
1171+
// For `std::round` with fallback to `round`:
1172+
// On some toolchains `std::round` is not available (e.g. GCC 6).
1173+
using namespace std;
11711174
num_fractional_digits =
11721175
count_fractional_digits<Duration::period::num,
11731176
Duration::period::den>::value;
1174-
if (num_fractional_digits < 6 && static_cast<rep>(std::round(val)) != val)
1177+
if (num_fractional_digits < 6 && static_cast<rep>(round(val)) != val)
11751178
num_fractional_digits = 6;
11761179
}
11771180

0 commit comments

Comments
 (0)