fixed chrono.h changes
This commit is contained in:
parent
9501da5796
commit
854bf9a6b8
@ -764,15 +764,13 @@ inline std::chrono::duration<Rep, std::milli> get_milliseconds(
|
|||||||
|
|
||||||
template <typename Char, typename Rep, typename OutputIt>
|
template <typename Char, typename Rep, typename OutputIt>
|
||||||
OutputIt format_duration_value(OutputIt out, Rep val, int precision) {
|
OutputIt format_duration_value(OutputIt out, Rep val, int precision) {
|
||||||
if (precision >= 0)
|
const Char pr_f[] = {'{', ':', '.', '{', '}', 'f', '}', 0};
|
||||||
return format_to(out, FMT_STRING("{:.{}f}"), val, precision);
|
if (precision >= 0) return vformat_to(out, pr_f, make_format_args(val, precision));
|
||||||
if (std::is_floating_point<Rep>::value) {
|
const Char fp_f[] = {'{', ':', 'g', '}', 0};
|
||||||
return format_to(out, FMT_STRING("{:g}"), val);
|
const Char format[] = {'{', '}', 0};
|
||||||
} else {
|
return vformat_to(out, std::is_floating_point<Rep>::value ? fp_f : format,
|
||||||
return format_to(out, FMT_STRING("{}"), val);
|
make_format_args(val));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char, typename OutputIt>
|
template <typename Char, typename OutputIt>
|
||||||
OutputIt copy_unit(string_view unit, OutputIt out, Char) {
|
OutputIt copy_unit(string_view unit, OutputIt out, Char) {
|
||||||
return std::copy(unit.begin(), unit.end(), out);
|
return std::copy(unit.begin(), unit.end(), out);
|
||||||
@ -790,9 +788,10 @@ template <typename Char, typename Period, typename OutputIt>
|
|||||||
OutputIt format_duration_unit(OutputIt out) {
|
OutputIt format_duration_unit(OutputIt out) {
|
||||||
if (const char* unit = get_units<Period>())
|
if (const char* unit = get_units<Period>())
|
||||||
return copy_unit(string_view(unit), out, Char());
|
return copy_unit(string_view(unit), out, Char());
|
||||||
if (const_check(Period::den == 1))
|
const Char num_f[] = {'[', '{', '}', ']', 's', 0};
|
||||||
return format_to(out, FMT_STRING("[{}]s"), Period::num);
|
if (const_check(Period::den == 1)) return vformat_to(out, num_f, make_format_args(Period::num));
|
||||||
return format_to(out, FMT_STRING("[{}/{}]s"), Period::num, Period::den);
|
const Char num_def_f[] = {'[', '{', '}', '/', '{', '}', ']', 's', 0};
|
||||||
|
return vformat_to(out, num_def_f, make_format_args(Period::num, Period::den));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FormatContext, typename OutputIt, typename Rep,
|
template <typename FormatContext, typename OutputIt, typename Rep,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user