mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-26 03:35:22 +00:00
write_floating_seconds
: Fall back to ::round
(#3343)
On some toolchains, `std::round` is not available. Fixes #3342
This commit is contained in:
parent
cbc7b8d5c1
commit
7f882918eb
@ -1168,10 +1168,13 @@ void write_floating_seconds(memory_buffer& buf, Duration duration,
|
||||
auto val = duration.count();
|
||||
|
||||
if (num_fractional_digits < 0) {
|
||||
// For `std::round` with fallback to `round`:
|
||||
// On some toolchains `std::round` is not available (e.g. GCC 6).
|
||||
using namespace std;
|
||||
num_fractional_digits =
|
||||
count_fractional_digits<Duration::period::num,
|
||||
Duration::period::den>::value;
|
||||
if (num_fractional_digits < 6 && static_cast<rep>(std::round(val)) != val)
|
||||
if (num_fractional_digits < 6 && static_cast<rep>(round(val)) != val)
|
||||
num_fractional_digits = 6;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user