forked from fmtlib/fmt
Consistently use fmt::
when invoking format_to
. (#3779)
This has been done partially in previous commits: *2ac6c5ca8b
*258000064d
*ba50c19e82
*5ab9d39253
A patch that includes the `std::error_code` changes here is upstream in vcpkg, so that will be able to be removed when updating to the next release.
This commit is contained in:
@@ -1156,7 +1156,7 @@ void write_floating_seconds(memory_buffer& buf, Duration duration,
|
|||||||
num_fractional_digits = 6;
|
num_fractional_digits = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
format_to(std::back_inserter(buf), FMT_STRING("{:.{}f}"),
|
fmt::format_to(std::back_inserter(buf), FMT_STRING("{:.{}f}"),
|
||||||
std::fmod(val * static_cast<rep>(Duration::period::num) /
|
std::fmod(val * static_cast<rep>(Duration::period::num) /
|
||||||
static_cast<rep>(Duration::period::den),
|
static_cast<rep>(Duration::period::den),
|
||||||
static_cast<rep>(60)),
|
static_cast<rep>(60)),
|
||||||
|
@@ -492,7 +492,8 @@ auto format_to_n(OutputIt out, size_t n, const S& format_str, Args&&... args)
|
|||||||
-> format_to_n_result<OutputIt> {
|
-> format_to_n_result<OutputIt> {
|
||||||
using traits = detail::fixed_buffer_traits;
|
using traits = detail::fixed_buffer_traits;
|
||||||
auto buf = detail::iterator_buffer<OutputIt, char, traits>(out, n);
|
auto buf = detail::iterator_buffer<OutputIt, char, traits>(out, n);
|
||||||
format_to(std::back_inserter(buf), format_str, std::forward<Args>(args)...);
|
fmt::format_to(std::back_inserter(buf), format_str,
|
||||||
|
std::forward<Args>(args)...);
|
||||||
return {buf.out(), buf.count()};
|
return {buf.out(), buf.count()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,8 +58,8 @@ FMT_FUNC void format_error_code(detail::buffer<char>& out, int error_code,
|
|||||||
error_code_size += detail::to_unsigned(detail::count_digits(abs_value));
|
error_code_size += detail::to_unsigned(detail::count_digits(abs_value));
|
||||||
auto it = buffer_appender<char>(out);
|
auto it = buffer_appender<char>(out);
|
||||||
if (message.size() <= inline_buffer_size - error_code_size)
|
if (message.size() <= inline_buffer_size - error_code_size)
|
||||||
format_to(it, FMT_STRING("{}{}"), message, SEP);
|
fmt::format_to(it, FMT_STRING("{}{}"), message, SEP);
|
||||||
format_to(it, FMT_STRING("{}{}"), ERROR_STR, error_code);
|
fmt::format_to(it, FMT_STRING("{}{}"), ERROR_STR, error_code);
|
||||||
FMT_ASSERT(out.size() <= inline_buffer_size, "");
|
FMT_ASSERT(out.size() <= inline_buffer_size, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1379,14 +1379,14 @@ template <> struct formatter<detail::bigint> {
|
|||||||
for (auto i = n.bigits_.size(); i > 0; --i) {
|
for (auto i = n.bigits_.size(); i > 0; --i) {
|
||||||
auto value = n.bigits_[i - 1u];
|
auto value = n.bigits_[i - 1u];
|
||||||
if (first) {
|
if (first) {
|
||||||
out = format_to(out, FMT_STRING("{:x}"), value);
|
out = fmt::format_to(out, FMT_STRING("{:x}"), value);
|
||||||
first = false;
|
first = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
out = format_to(out, FMT_STRING("{:08x}"), value);
|
out = fmt::format_to(out, FMT_STRING("{:08x}"), value);
|
||||||
}
|
}
|
||||||
if (n.exp_ > 0)
|
if (n.exp_ > 0)
|
||||||
out = format_to(out, FMT_STRING("p{}"),
|
out = fmt::format_to(out, FMT_STRING("p{}"),
|
||||||
n.exp_ * detail::bigint::bigit_bits);
|
n.exp_ * detail::bigint::bigit_bits);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@@ -867,7 +867,7 @@ enum { inline_buffer_size = 500 };
|
|||||||
**Example**::
|
**Example**::
|
||||||
|
|
||||||
auto out = fmt::memory_buffer();
|
auto out = fmt::memory_buffer();
|
||||||
format_to(std::back_inserter(out), "The answer is {}.", 42);
|
fmt::format_to(std::back_inserter(out), "The answer is {}.", 42);
|
||||||
|
|
||||||
This will append the following output to the ``out`` object:
|
This will append the following output to the ``out`` object:
|
||||||
|
|
||||||
|
@@ -587,7 +587,7 @@ template <class charT> struct formatter<std::complex<double>, charT> {
|
|||||||
fmt::runtime("{:" + specs + "}"), c.imag());
|
fmt::runtime("{:" + specs + "}"), c.imag());
|
||||||
auto fill_align_width = std::string();
|
auto fill_align_width = std::string();
|
||||||
if (specs_.width > 0) fill_align_width = fmt::format(">{}", specs_.width);
|
if (specs_.width > 0) fill_align_width = fmt::format(">{}", specs_.width);
|
||||||
return format_to(ctx.out(), runtime("{:" + fill_align_width + "}"),
|
return fmt::format_to(ctx.out(), runtime("{:" + fill_align_width + "}"),
|
||||||
c.real() != 0 ? fmt::format("({}+{}i)", real, imag)
|
c.real() != 0 ? fmt::format("({}+{}i)", real, imag)
|
||||||
: fmt::format("{}i", imag));
|
: fmt::format("{}i", imag));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user