Fix MSVC issue with FMT_ENFORCE_COMPILE_STRING
This commit is contained in:
parent
4a6eadbde0
commit
e3210ff5eb
@ -769,7 +769,14 @@ template <typename Char, typename Rep, typename OutputIt,
|
||||
FMT_ENABLE_IF(std::is_integral<Rep>::value)>
|
||||
OutputIt format_duration_value(OutputIt out, Rep val, int) {
|
||||
static FMT_CONSTEXPR_DECL const Char format[] = {'{', '}', 0};
|
||||
return format_to(out, compile_string_to_view(format), val);
|
||||
|
||||
// Workaround a compiler error in MSVC <= 16.8.2
|
||||
#if FMT_MSC_VER && FMT_MSC_VER <= 1928
|
||||
return vformat_to(out, to_string_view(format),
|
||||
make_format_args<buffer_context<Char>>(val));
|
||||
#else
|
||||
return format_to(out, FMT_STRING(format), val);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename Char, typename Rep, typename OutputIt,
|
||||
@ -777,10 +784,22 @@ template <typename Char, typename Rep, typename OutputIt,
|
||||
OutputIt format_duration_value(OutputIt out, Rep val, int precision) {
|
||||
static FMT_CONSTEXPR_DECL const Char pr_f[] = {'{', ':', '.', '{',
|
||||
'}', 'f', '}', 0};
|
||||
if (precision >= 0)
|
||||
return format_to(out, compile_string_to_view(pr_f), val, precision);
|
||||
if (precision >= 0) {
|
||||
#if FMT_MSC_VER && FMT_MSC_VER <= 1928
|
||||
return vformat_to(out, to_string_view(pr_f),
|
||||
make_format_args<buffer_context<Char>>(val, precision));
|
||||
#else
|
||||
return format_to(out, FMT_STRING(pr_f), val, precision);
|
||||
#endif
|
||||
}
|
||||
static FMT_CONSTEXPR_DECL const Char fp_f[] = {'{', ':', 'g', '}', 0};
|
||||
return format_to(out, compile_string_to_view(fp_f), val);
|
||||
|
||||
#if FMT_MSC_VER && FMT_MSC_VER <= 1928
|
||||
return vformat_to(out, to_string_view(fp_f),
|
||||
make_format_args<buffer_context<Char>>(val));
|
||||
#else
|
||||
return format_to(out, FMT_STRING(fp_f), val);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename Char, typename OutputIt>
|
||||
@ -801,12 +820,23 @@ OutputIt format_duration_unit(OutputIt out) {
|
||||
if (const char* unit = get_units<Period>())
|
||||
return copy_unit(string_view(unit), out, Char());
|
||||
static FMT_CONSTEXPR_DECL const Char num_f[] = {'[', '{', '}', ']', 's', 0};
|
||||
if (const_check(Period::den == 1))
|
||||
return format_to(out, compile_string_to_view(num_f), Period::num);
|
||||
if (const_check(Period::den == 1)) {
|
||||
#if FMT_MSC_VER && FMT_MSC_VER <= 1928
|
||||
return vformat_to(out, to_string_view(num_f),
|
||||
make_format_args<buffer_context<Char>>(Period::num));
|
||||
#else
|
||||
return format_to(out, FMT_STRING(num_f), Period::num);
|
||||
#endif
|
||||
}
|
||||
static FMT_CONSTEXPR_DECL const Char num_def_f[] = {'[', '{', '}', '/', '{',
|
||||
'}', ']', 's', 0};
|
||||
return format_to(out, compile_string_to_view(num_def_f), Period::num,
|
||||
Period::den);
|
||||
#if FMT_MSC_VER && FMT_MSC_VER <= 1928
|
||||
return vformat_to(
|
||||
out, to_string_view(num_def_f),
|
||||
make_format_args<buffer_context<Char>>(Period::num, Period::den));
|
||||
#else
|
||||
return format_to(out, FMT_STRING(num_def_f), Period::num, Period::den);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename FormatContext, typename OutputIt, typename Rep,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user