* Eliminate warnings
* Possibly fix bizarre ambiguity on OSX's AppleClang for the detail::count_digits() function according to https://github.com/gabime/spdlog/issues/914
This commit is contained in:
parent
1067285501
commit
7cc94ba0bc
@ -876,6 +876,8 @@ template <typename T> struct make_unsigned_or_unchanged<T, true> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if FMT_USE_CONSTEXPR
|
#if FMT_USE_CONSTEXPR
|
||||||
|
// Taken from MSVC <chrono> STL implementation
|
||||||
|
// Copyright (c) Microsoft Corporation 2021
|
||||||
template <class Duration> FMT_CONSTEXPR unsigned int get_fractional_width() {
|
template <class Duration> FMT_CONSTEXPR unsigned int get_fractional_width() {
|
||||||
static_assert(Duration::period::num > 0 && Duration::period::den > 0,
|
static_assert(Duration::period::num > 0 && Duration::period::den > 0,
|
||||||
"Numerator and denominator can't be less than 1.");
|
"Numerator and denominator can't be less than 1.");
|
||||||
@ -938,14 +940,16 @@ To fmt_safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> from) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <class Duration> struct subsecond_helper {
|
template <class Duration> struct subsecond_helper {
|
||||||
static constexpr std::uintmax_t fractional_width =
|
static constexpr std::uint64_t fractional_width =
|
||||||
#if FMT_USE_CONSTEXPR
|
#if FMT_USE_CONSTEXPR
|
||||||
get_fractional_width<Duration>();
|
get_fractional_width<Duration>();
|
||||||
#else
|
#else
|
||||||
width<Duration::period::num, Duration::period::den>::value;
|
width<Duration::period::num, Duration::period::den>::value > 18
|
||||||
|
? 6
|
||||||
|
: width<Duration::period::num, Duration::period::den>::value;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static constexpr std::uintmax_t fractional_width_pow10 =
|
static constexpr std::uint64_t fractional_width_pow10 =
|
||||||
#if FMT_USE_CONSTEXPR
|
#if FMT_USE_CONSTEXPR
|
||||||
pow10(fractional_width);
|
pow10(fractional_width);
|
||||||
#else
|
#else
|
||||||
@ -1204,11 +1208,12 @@ struct chrono_formatter {
|
|||||||
const auto tmpval = std::chrono::duration<Rep, Period>(val);
|
const auto tmpval = std::chrono::duration<Rep, Period>(val);
|
||||||
#endif
|
#endif
|
||||||
using subsec_helper = detail::subsecond_helper<duration_Rep>;
|
using subsec_helper = detail::subsecond_helper<duration_Rep>;
|
||||||
const std::uintmax_t subseconds =
|
const std::uint64_t subseconds =
|
||||||
subsec_helper::get_subseconds(tmpval).count();
|
subsec_helper::get_subseconds(tmpval).count();
|
||||||
if (subseconds > 0) {
|
if (subseconds > 0) {
|
||||||
*out++ = '.';
|
*out++ = '.';
|
||||||
const auto num_digits = detail::count_digits(subseconds);
|
const std::uint32_t num_digits =
|
||||||
|
detail::count_digits(static_cast<std::uint64_t>(subseconds));
|
||||||
if (subsec_helper::fractional_width > num_digits) {
|
if (subsec_helper::fractional_width > num_digits) {
|
||||||
out = std::fill_n(out, subsec_helper::fractional_width - num_digits,
|
out = std::fill_n(out, subsec_helper::fractional_width - num_digits,
|
||||||
'0');
|
'0');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user