mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-31 03:07:36 +02:00
Unbloat chrono
This commit is contained in:
@ -2279,7 +2279,7 @@ struct formatter<std::chrono::duration<Rep, Period>, Char> {
|
|||||||
// As a possible future optimization, we could avoid extra copying if width
|
// As a possible future optimization, we could avoid extra copying if width
|
||||||
// is not specified.
|
// is not specified.
|
||||||
auto buf = basic_memory_buffer<Char>();
|
auto buf = basic_memory_buffer<Char>();
|
||||||
auto out = std::back_inserter(buf);
|
auto out = basic_appender<Char>(buf);
|
||||||
detail::handle_dynamic_spec<detail::width_checker>(specs.width, width_ref_,
|
detail::handle_dynamic_spec<detail::width_checker>(specs.width, width_ref_,
|
||||||
ctx);
|
ctx);
|
||||||
detail::handle_dynamic_spec<detail::precision_checker>(precision,
|
detail::handle_dynamic_spec<detail::precision_checker>(precision,
|
||||||
@ -2388,7 +2388,7 @@ template <typename Char> struct formatter<std::tm, Char> {
|
|||||||
const Duration* subsecs) const -> decltype(ctx.out()) {
|
const Duration* subsecs) const -> decltype(ctx.out()) {
|
||||||
auto specs = specs_;
|
auto specs = specs_;
|
||||||
auto buf = basic_memory_buffer<Char>();
|
auto buf = basic_memory_buffer<Char>();
|
||||||
auto out = std::back_inserter(buf);
|
auto out = basic_appender<Char>(buf);
|
||||||
detail::handle_dynamic_spec<detail::width_checker>(specs.width, width_ref_,
|
detail::handle_dynamic_spec<detail::width_checker>(specs.width, width_ref_,
|
||||||
ctx);
|
ctx);
|
||||||
|
|
||||||
|
@ -494,9 +494,9 @@ auto format_to_n(OutputIt out, size_t n, const S& fmt, Args&&... args)
|
|||||||
|
|
||||||
template <typename S, typename... Args,
|
template <typename S, typename... Args,
|
||||||
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
|
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
|
||||||
FMT_CONSTEXPR20 auto formatted_size(const S& fmt, const Args&... args)
|
auto formatted_size(const S& fmt, const Args&... args) -> size_t {
|
||||||
-> size_t {
|
auto buf = detail::counting_buffer<>();
|
||||||
return fmt::format_to(detail::counting_iterator(), fmt, args...).count();
|
return fmt::format_to(fmt::appender(buf), fmt, args...).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename S, typename... Args,
|
template <typename S, typename... Args,
|
||||||
|
@ -1314,10 +1314,10 @@ FMT_CONSTEXPR20 auto format_decimal(Char* out, UInt value, int size)
|
|||||||
return {begin + n, end};
|
return {begin + n, end};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char, typename UInt, typename Iterator,
|
template <typename Char, typename UInt, typename OutputIt,
|
||||||
FMT_ENABLE_IF(!std::is_pointer<remove_cvref_t<Iterator>>::value)>
|
FMT_ENABLE_IF(is_back_insert_iterator<OutputIt>::value)>
|
||||||
FMT_CONSTEXPR inline auto format_decimal(Iterator out, UInt value, int size)
|
FMT_CONSTEXPR inline auto format_decimal(OutputIt out, UInt value, int size)
|
||||||
-> format_decimal_result<Iterator> {
|
-> format_decimal_result<OutputIt> {
|
||||||
// Buffer is large enough to hold all digits (digits10 + 1).
|
// Buffer is large enough to hold all digits (digits10 + 1).
|
||||||
Char buffer[digits10<UInt>() + 1] = {};
|
Char buffer[digits10<UInt>() + 1] = {};
|
||||||
auto end = format_decimal(buffer, value, size).end;
|
auto end = format_decimal(buffer, value, size).end;
|
||||||
|
@ -206,7 +206,7 @@ TEST(compile_test, format_to_n) {
|
|||||||
EXPECT_STREQ("2a", buffer);
|
EXPECT_STREQ("2a", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef __cpp_lib_bit_cast
|
# if 0
|
||||||
TEST(compile_test, constexpr_formatted_size) {
|
TEST(compile_test, constexpr_formatted_size) {
|
||||||
FMT_CONSTEXPR20 size_t size = fmt::formatted_size(FMT_COMPILE("{}"), 42);
|
FMT_CONSTEXPR20 size_t size = fmt::formatted_size(FMT_COMPILE("{}"), 42);
|
||||||
EXPECT_EQ(size, 2);
|
EXPECT_EQ(size, 2);
|
||||||
|
Reference in New Issue
Block a user