From 5488d0b53acc339af386d9253bfa569183039784 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 7 Jul 2019 06:39:20 -0700 Subject: [PATCH] spec -> specs --- include/fmt/chrono.h | 14 ++-- include/fmt/format-inl.h | 14 ++-- include/fmt/format.h | 153 ++++++++++++++++------------------ include/fmt/printf.h | 99 +++++++++++----------- test/custom-formatter-test.cc | 2 +- test/printf-test.cc | 6 +- 6 files changed, 138 insertions(+), 150 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 95a6f46f..a71638e1 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -715,7 +715,7 @@ struct chrono_formatter { template struct formatter, Char> { private: - basic_format_specs spec; + basic_format_specs specs; int precision; typedef internal::arg_ref arg_ref_type; arg_ref_type width_ref; @@ -744,9 +744,9 @@ struct formatter, Char> { } void on_error(const char* msg) { FMT_THROW(format_error(msg)); } - void on_fill(Char fill) { f.spec.fill[0] = fill; } - void on_align(align_t align) { f.spec.align = align; } - void on_width(unsigned width) { f.spec.width = width; } + void on_fill(Char fill) { f.specs.fill[0] = fill; } + void on_align(align_t align) { f.specs.align = align; } + void on_width(unsigned width) { f.specs.width = width; } void on_precision(unsigned precision) { f.precision = precision; } void end_precision() {} @@ -784,7 +784,7 @@ struct formatter, Char> { } public: - formatter() : spec(), precision(-1) {} + formatter() : precision(-1) {} FMT_CONSTEXPR auto parse(basic_parse_context& ctx) -> decltype(ctx.begin()) { @@ -804,7 +804,7 @@ struct formatter, Char> { using range = internal::output_range; internal::basic_writer w(range(ctx.out())); internal::handle_dynamic_spec( - spec.width, width_ref, ctx, format_str.begin()); + specs.width, width_ref, ctx, format_str.begin()); internal::handle_dynamic_spec( precision, precision_ref, ctx, format_str.begin()); if (begin == end || *begin == '}') { @@ -816,7 +816,7 @@ struct formatter, Char> { f.precision = precision; parse_chrono_format(begin, end, f); } - w.write(buf.data(), buf.size(), spec); + w.write(buf.data(), buf.size(), specs); return w.out(); } }; diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 622a03e3..dd3ccb4f 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -754,7 +754,7 @@ FMT_API bool grisu_format(Double value, buffer& buf, int precision, template char* sprintf_format(Double value, internal::buffer& buf, - core_format_specs spec) { + core_format_specs specs) { // Buffer capacity must be non-zero, otherwise MSVC's vsnprintf_s will fail. FMT_ASSERT(buf.capacity() != 0, "empty buffer"); @@ -763,14 +763,14 @@ char* sprintf_format(Double value, internal::buffer& buf, char format[max_format_size]; char* format_ptr = format; *format_ptr++ = '%'; - if (spec.alt || !spec.type) *format_ptr++ = '#'; - if (spec.precision >= 0) { + if (specs.alt || !specs.type) *format_ptr++ = '#'; + if (specs.precision >= 0) { *format_ptr++ = '.'; *format_ptr++ = '*'; } if (std::is_same::value) *format_ptr++ = 'L'; - char type = spec.type; + char type = specs.type; if (type == '%') type = 'f'; @@ -792,18 +792,18 @@ char* sprintf_format(Double value, internal::buffer& buf, std::size_t buffer_size = buf.capacity(); start = &buf[0]; int result = - format_float(start, buffer_size, format, spec.precision, value); + format_float(start, buffer_size, format, specs.precision, value); if (result >= 0) { unsigned n = internal::to_unsigned(result); if (n < buf.capacity()) { // Find the decimal point. auto p = buf.data(), end = p + n; if (*p == '+' || *p == '-') ++p; - if (spec.type != 'a' && spec.type != 'A') { + if (specs.type != 'a' && specs.type != 'A') { while (p < end && *p >= '0' && *p <= '9') ++p; if (p < end && *p != 'e' && *p != 'E') { decimal_point_pos = p; - if (!spec.type) { + if (!specs.type) { // Keep only one trailing zero after the decimal point. ++p; if (*p == '0') ++p; diff --git a/include/fmt/format.h b/include/fmt/format.h index e31742a1..02458d76 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1280,24 +1280,23 @@ template class basic_writer { // Writes an integer in the format // // where are written by f(it). - template - void write_int(int num_digits, string_view prefix, const Spec& spec, F f) { + template + void write_int(int num_digits, string_view prefix, format_specs specs, F f) { std::size_t size = prefix.size() + internal::to_unsigned(num_digits); - char_type fill = spec.fill[0]; + char_type fill = specs.fill[0]; std::size_t padding = 0; - if (spec.align == align::numeric) { - if (internal::to_unsigned(spec.width) > size) { - padding = spec.width - size; - size = spec.width; + if (specs.align == align::numeric) { + if (internal::to_unsigned(specs.width) > size) { + padding = specs.width - size; + size = specs.width; } - } else if (spec.precision > num_digits) { - size = prefix.size() + internal::to_unsigned(spec.precision); - padding = internal::to_unsigned(spec.precision - num_digits); + } else if (specs.precision > num_digits) { + size = prefix.size() + internal::to_unsigned(specs.precision); + padding = internal::to_unsigned(specs.precision - num_digits); fill = static_cast('0'); } - format_specs as = spec; - if (spec.align == align::none) as.align = align::right; - write_padded(as, padded_int_writer{size, prefix, fill, padding, f}); + if (specs.align == align::none) specs.align = align::right; + write_padded(specs, padded_int_writer{size, prefix, fill, padding, f}); } // Writes a decimal integer. @@ -1313,28 +1312,28 @@ template class basic_writer { } // The handle_int_type_spec handler that writes an integer. - template struct int_writer { + template struct int_writer { using unsigned_type = uint32_or_64_t; basic_writer& writer; - const Spec& spec; + const Specs& specs; unsigned_type abs_value; char prefix[4]; unsigned prefix_size; string_view get_prefix() const { return string_view(prefix, prefix_size); } - int_writer(basic_writer& w, Int value, const Spec& s) + int_writer(basic_writer& w, Int value, const Specs& s) : writer(w), - spec(s), + specs(s), abs_value(static_cast(value)), prefix_size(0) { if (internal::is_negative(value)) { prefix[0] = '-'; ++prefix_size; abs_value = 0 - abs_value; - } else if (spec.sign != sign::none && spec.sign != sign::minus) { - prefix[0] = spec.sign == sign::plus ? '+' : ' '; + } else if (specs.sign != sign::none && specs.sign != sign::minus) { + prefix[0] = specs.sign == sign::plus ? '+' : ' '; ++prefix_size; } } @@ -1350,7 +1349,7 @@ template class basic_writer { void on_dec() { int num_digits = internal::count_digits(abs_value); - writer.write_int(num_digits, get_prefix(), spec, + writer.write_int(num_digits, get_prefix(), specs, dec_writer{abs_value, num_digits}); } @@ -1360,17 +1359,17 @@ template class basic_writer { template void operator()(It&& it) const { it = internal::format_uint<4, char_type>(it, self.abs_value, num_digits, - self.spec.type != 'x'); + self.specs.type != 'x'); } }; void on_hex() { - if (spec.alt) { + if (specs.alt) { prefix[prefix_size++] = '0'; - prefix[prefix_size++] = spec.type; + prefix[prefix_size++] = specs.type; } int num_digits = internal::count_digits<4>(abs_value); - writer.write_int(num_digits, get_prefix(), spec, + writer.write_int(num_digits, get_prefix(), specs, hex_writer{*this, num_digits}); } @@ -1384,23 +1383,23 @@ template class basic_writer { }; void on_bin() { - if (spec.alt) { + if (specs.alt) { prefix[prefix_size++] = '0'; - prefix[prefix_size++] = static_cast(spec.type); + prefix[prefix_size++] = static_cast(specs.type); } int num_digits = internal::count_digits<1>(abs_value); - writer.write_int(num_digits, get_prefix(), spec, + writer.write_int(num_digits, get_prefix(), specs, bin_writer<1>{abs_value, num_digits}); } void on_oct() { int num_digits = internal::count_digits<3>(abs_value); - if (spec.alt && spec.precision <= num_digits) { + if (specs.alt && specs.precision <= num_digits) { // Octal prefix '0' is counted as a digit, so only add it if precision // is not greater than the number of digits. prefix[prefix_size++] = '0'; } - writer.write_int(num_digits, get_prefix(), spec, + writer.write_int(num_digits, get_prefix(), specs, bin_writer<3>{abs_value, num_digits}); } @@ -1430,7 +1429,7 @@ template class basic_writer { int num_digits = internal::count_digits(abs_value); char_type sep = internal::thousands_sep(writer.locale_); int size = num_digits + SEP_SIZE * ((num_digits - 1) / 3); - writer.write_int(size, get_prefix(), spec, + writer.write_int(size, get_prefix(), specs, num_writer{abs_value, size, sep}); } @@ -1559,18 +1558,18 @@ template class basic_writer { // Writes a value in the format // // where is written by f(it). - template void write_padded(const format_specs& spec, F&& f) { - unsigned width = spec.width; // User-perceived width (in code points). - size_t size = f.size(); // The number of code units. + template void write_padded(const format_specs& specs, F&& f) { + unsigned width = specs.width; // User-perceived width (in code points). + size_t size = f.size(); // The number of code units. size_t num_code_points = width != 0 ? f.width() : size; if (width <= num_code_points) return f(reserve(size)); auto&& it = reserve(width + (size - num_code_points)); - char_type fill = spec.fill[0]; + char_type fill = specs.fill[0]; std::size_t padding = width - num_code_points; - if (spec.align == align::right) { + if (specs.align == align::right) { it = std::fill_n(it, padding, fill); f(it); - } else if (spec.align == align::center) { + } else if (specs.align == align::center) { std::size_t left_padding = padding / 2; it = std::fill_n(it, left_padding, fill); f(it); @@ -1596,21 +1595,8 @@ template class basic_writer { int_writer(*this, value, spec)); } - /** - \rst - Formats *value* and writes it to the buffer. - \endrst - */ - template ::value)> - void write(T value, FormatSpec spec, FormatSpecs... specs) { - format_specs s(spec, specs...); - s.align = align::right; - write_int(value, s); - } - - void write(double value, const format_specs& spec = format_specs()) { - write_double(value, spec); + void write(double value, const format_specs& specs = format_specs()) { + write_double(value, specs); } /** @@ -1619,13 +1605,13 @@ template class basic_writer { (``'g'``) and writes it to the buffer. \endrst */ - void write(long double value, const format_specs& spec = format_specs()) { - write_double(value, spec); + void write(long double value, const format_specs& specs = format_specs()) { + write_double(value, specs); } // Formats a floating-point number (double or long double). template ()> - void write_double(T value, const format_specs& spec); + void write_double(T value, const format_specs& specs); /** Writes a character to the buffer. */ void write(char value) { @@ -1656,28 +1642,28 @@ template class basic_writer { // Writes a formatted string. template - void write(const Char* s, std::size_t size, const format_specs& spec) { - write_padded(spec, str_writer{s, size}); + void write(const Char* s, std::size_t size, const format_specs& specs) { + write_padded(specs, str_writer{s, size}); } template void write(basic_string_view s, - const format_specs& spec = format_specs()) { + const format_specs& specs = format_specs()) { const Char* data = s.data(); std::size_t size = s.size(); - if (spec.precision >= 0 && internal::to_unsigned(spec.precision) < size) - size = internal::to_unsigned(spec.precision); - write(data, size, spec); + if (specs.precision >= 0 && internal::to_unsigned(specs.precision) < size) + size = internal::to_unsigned(specs.precision); + write(data, size, specs); } template - void write_pointer(UIntPtr value, const format_specs* spec) { + void write_pointer(UIntPtr value, const format_specs* specs) { int num_digits = internal::count_digits<4>(value); auto pw = pointer_writer{value, num_digits}; - if (!spec) return pw(reserve(num_digits + 2)); - format_specs as = *spec; - if (as.align == align::none) as.align = align::right; - write_padded(as, pw); + if (!specs) return pw(reserve(num_digits + 2)); + format_specs specs_copy = *specs; + if (specs_copy.align == align::none) specs_copy.align = align::right; + write_padded(specs_copy, pw); } }; @@ -1717,7 +1703,8 @@ class arg_formatter_base { protected: writer_type& writer() { return writer_; } - format_specs* spec() { return specs_; } + FMT_DEPRECATED format_specs* spec() { return specs_; } + format_specs* specs() { return specs_; } iterator out() { return writer_.out(); } void write(bool value) { @@ -2600,13 +2587,13 @@ class arg_formatter : public internal::arg_formatter_base { \rst Constructs an argument formatter object. *ctx* is a reference to the formatting context, - *spec* contains format specifier information for standard argument types. + *specs* contains format specifier information for standard argument types. \endrst */ explicit arg_formatter(context_type& ctx, basic_parse_context* parse_ctx = nullptr, - format_specs* spec = nullptr) - : base(Range(ctx.out()), spec, ctx.locale()), + format_specs* specs = nullptr) + : base(Range(ctx.out()), specs, ctx.locale()), ctx_(ctx), parse_ctx_(parse_ctx) {} @@ -2726,9 +2713,9 @@ struct float_spec_handler { template template void internal::basic_writer::write_double(T value, - const format_specs& spec) { + const format_specs& specs) { // Check type. - float_spec_handler handler(static_cast(spec.type)); + float_spec_handler handler(static_cast(specs.type)); internal::handle_float_type_spec(handler.type, handler); char sign = 0; @@ -2736,10 +2723,10 @@ void internal::basic_writer::write_double(T value, if (std::signbit(value)) { sign = '-'; value = -value; - } else if (spec.sign != sign::none) { - if (spec.sign == sign::plus) + } else if (specs.sign != sign::none) { + if (specs.sign == sign::plus) sign = '+'; - else if (spec.sign == sign::space) + else if (specs.sign == sign::space) sign = ' '; } @@ -2748,7 +2735,7 @@ void internal::basic_writer::write_double(T value, // consistent across platforms. const char* str = std::isinf(value) ? (handler.upper ? "INF" : "inf") : (handler.upper ? "NAN" : "nan"); - return write_padded(spec, + return write_padded(specs, inf_or_nan_writer{sign, handler.as_percentage, str}); } @@ -2756,23 +2743,23 @@ void internal::basic_writer::write_double(T value, memory_buffer buffer; int exp = 0; - int precision = spec.precision >= 0 || !spec.type ? spec.precision : 6; + int precision = specs.precision >= 0 || !specs.type ? specs.precision : 6; unsigned options = handler.fixed ? internal::grisu_options::fixed : 0; bool use_grisu = USE_GRISU && - (spec.type != 'a' && spec.type != 'A' && spec.type != 'e' && - spec.type != 'E') && + (specs.type != 'a' && specs.type != 'A' && + specs.type != 'e' && specs.type != 'E') && internal::grisu_format(static_cast(value), buffer, precision, options, exp); char* decimal_point_pos = nullptr; if (!use_grisu) - decimal_point_pos = internal::sprintf_format(value, buffer, spec); + decimal_point_pos = internal::sprintf_format(value, buffer, specs); if (handler.as_percentage) { buffer.push_back('%'); --exp; // Adjust decimal place position. } - format_specs as = spec; - if (spec.align == align::numeric) { + format_specs as = specs; + if (specs.align == align::numeric) { if (sign) { auto&& it = reserve(1); *it++ = static_cast(sign); @@ -2780,7 +2767,7 @@ void internal::basic_writer::write_double(T value, if (as.width) --as.width; } as.align = align::right; - } else if (spec.align == align::none) { + } else if (specs.align == align::none) { as.align = align::right; } char_type decimal_point = handler.use_locale @@ -2791,7 +2778,7 @@ void internal::basic_writer::write_double(T value, params.fixed = handler.fixed; params.num_digits = precision; params.trailing_zeros = - (precision != 0 && (handler.fixed || !spec.type)) || spec.alt; + (precision != 0 && (handler.fixed || !specs.type)) || specs.alt; write_padded(as, grisu_writer(sign, buffer, exp, params, decimal_point)); } else { write_padded(as, diff --git a/include/fmt/printf.h b/include/fmt/printf.h index 4392d1c4..77c2ee8f 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -151,16 +151,16 @@ template class printf_width_handler { private: typedef basic_format_specs format_specs; - format_specs& spec_; + format_specs& specs_; public: - explicit printf_width_handler(format_specs& spec) : spec_(spec) {} + explicit printf_width_handler(format_specs& specs) : specs_(specs) {} template ::value)> unsigned operator()(T value) { auto width = static_cast>(value); if (internal::is_negative(value)) { - spec_.align = align::left; + specs_.align = align::left; width = 0 - width; } unsigned int_max = std::numeric_limits::max(); @@ -213,12 +213,12 @@ class printf_arg_formatter : public internal::arg_formatter_base { context_type& context_; void write_null_pointer(char) { - this->spec()->type = 0; + this->specs()->type = 0; this->write("(nil)"); } void write_null_pointer(wchar_t) { - this->spec()->type = 0; + this->specs()->type = 0; this->write(L"(nil)"); } @@ -228,29 +228,29 @@ class printf_arg_formatter : public internal::arg_formatter_base { /** \rst Constructs an argument formatter object. - *buffer* is a reference to the output buffer and *spec* contains format + *buffer* is a reference to the output buffer and *specs* contains format specifier information for standard argument types. \endrst */ - printf_arg_formatter(iterator iter, format_specs& spec, context_type& ctx) - : base(Range(iter), &spec, internal::locale_ref()), context_(ctx) {} + printf_arg_formatter(iterator iter, format_specs& specs, context_type& ctx) + : base(Range(iter), &specs, internal::locale_ref()), context_(ctx) {} template ::value)> iterator operator()(T value) { // MSVC2013 fails to compile separate overloads for bool and char_type so // use std::is_same instead. if (std::is_same::value) { - format_specs& fmt_spec = *this->spec(); - if (fmt_spec.type != 's') return base::operator()(value ? 1 : 0); - fmt_spec.type = 0; + format_specs& fmt_specs = *this->specs(); + if (fmt_specs.type != 's') return base::operator()(value ? 1 : 0); + fmt_specs.type = 0; this->write(value != 0); } else if (std::is_same::value) { - format_specs& fmt_spec = *this->spec(); - if (fmt_spec.type && fmt_spec.type != 'c') + format_specs& fmt_specs = *this->specs(); + if (fmt_specs.type && fmt_specs.type != 'c') return (*this)(static_cast(value)); - fmt_spec.sign = sign::none; - fmt_spec.alt = false; - fmt_spec.align = align::right; + fmt_specs.sign = sign::none; + fmt_specs.alt = false; + fmt_specs.align = align::right; return base::operator()(value); } else { return base::operator()(value); @@ -267,7 +267,7 @@ class printf_arg_formatter : public internal::arg_formatter_base { iterator operator()(const char* value) { if (value) base::operator()(value); - else if (this->spec()->type == 'p') + else if (this->specs()->type == 'p') write_null_pointer(char_type()); else this->write("(null)"); @@ -278,7 +278,7 @@ class printf_arg_formatter : public internal::arg_formatter_base { iterator operator()(const wchar_t* value) { if (value) base::operator()(value); - else if (this->spec()->type == 'p') + else if (this->specs()->type == 'p') write_null_pointer(char_type()); else this->write(L"(null)"); @@ -294,7 +294,7 @@ class printf_arg_formatter : public internal::arg_formatter_base { /** Formats a pointer. */ iterator operator()(const void* value) { if (value) return base::operator()(value); - this->spec()->type = 0; + this->specs()->type = 0; write_null_pointer(char_type()); return this->out(); } @@ -334,14 +334,15 @@ template class basic_printf_context { basic_format_args args_; basic_parse_context parse_ctx_; - static void parse_flags(format_specs& spec, const Char*& it, const Char* end); + static void parse_flags(format_specs& specs, const Char*& it, + const Char* end); // Returns the argument with specified index or, if arg_index is equal // to the maximum unsigned value, the next argument. format_arg get_arg(unsigned arg_index = std::numeric_limits::max()); // Parses argument index, flags and width and returns the argument index. - unsigned parse_header(const Char*& it, const Char* end, format_specs& spec); + unsigned parse_header(const Char*& it, const Char* end, format_specs& specs); public: /** @@ -373,25 +374,25 @@ template class basic_printf_context { }; template -void basic_printf_context::parse_flags(format_specs& spec, +void basic_printf_context::parse_flags(format_specs& specs, const Char*& it, const Char* end) { for (; it != end; ++it) { switch (*it) { case '-': - spec.align = align::left; + specs.align = align::left; break; case '+': - spec.sign = sign::plus; + specs.sign = sign::plus; break; case '0': - spec.fill[0] = '0'; + specs.fill[0] = '0'; break; case ' ': - spec.sign = sign::space; + specs.sign = sign::space; break; case '#': - spec.alt = true; + specs.alt = true; break; default: return; @@ -411,7 +412,7 @@ basic_printf_context::get_arg(unsigned arg_index) { template unsigned basic_printf_context::parse_header( - const Char*& it, const Char* end, format_specs& spec) { + const Char*& it, const Char* end, format_specs& specs) { unsigned arg_index = std::numeric_limits::max(); char_type c = *it; if (c >= '0' && c <= '9') { @@ -423,25 +424,25 @@ unsigned basic_printf_context::parse_header( ++it; arg_index = value; } else { - if (c == '0') spec.fill[0] = '0'; + if (c == '0') specs.fill[0] = '0'; if (value != 0) { // Nonzero value means that we parsed width and don't need to // parse it or flags again, so return now. - spec.width = value; + specs.width = value; return arg_index; } } } - parse_flags(spec, it, end); + parse_flags(specs, it, end); // Parse width. if (it != end) { if (*it >= '0' && *it <= '9') { internal::error_handler eh; - spec.width = parse_nonnegative_int(it, end, eh); + specs.width = parse_nonnegative_int(it, end, eh); } else if (*it == '*') { ++it; - spec.width = visit_format_arg( - internal::printf_width_handler(spec), get_arg()); + specs.width = visit_format_arg( + internal::printf_width_handler(specs), get_arg()); } } return arg_index; @@ -464,11 +465,11 @@ OutputIt basic_printf_context::format() { } out = std::copy(start, it - 1, out); - format_specs spec; - spec.align = align::right; + format_specs specs; + specs.align = align::right; // Parse argument index, flags and width. - unsigned arg_index = parse_header(it, end, spec); + unsigned arg_index = parse_header(it, end, specs); // Parse precision. if (it != end && *it == '.') { @@ -476,24 +477,24 @@ OutputIt basic_printf_context::format() { c = it != end ? *it : 0; if ('0' <= c && c <= '9') { internal::error_handler eh; - spec.precision = static_cast(parse_nonnegative_int(it, end, eh)); + specs.precision = static_cast(parse_nonnegative_int(it, end, eh)); } else if (c == '*') { ++it; - spec.precision = + specs.precision = visit_format_arg(internal::printf_precision_handler(), get_arg()); } else { - spec.precision = 0; + specs.precision = 0; } } format_arg arg = get_arg(arg_index); - if (spec.alt && visit_format_arg(internal::is_zero_int(), arg)) - spec.alt = false; - if (spec.fill[0] == '0') { + if (specs.alt && visit_format_arg(internal::is_zero_int(), arg)) + specs.alt = false; + if (specs.fill[0] == '0') { if (arg.is_arithmetic()) - spec.align = align::numeric; + specs.align = align::numeric; else - spec.fill[0] = ' '; // Ignore '0' flag for non-numeric types. + specs.fill[0] = ' '; // Ignore '0' flag for non-numeric types. } // Parse length and convert the argument to the required type. @@ -539,13 +540,13 @@ OutputIt basic_printf_context::format() { // Parse type. if (it == end) FMT_THROW(format_error("invalid format string")); - spec.type = static_cast(*it++); + specs.type = static_cast(*it++); if (arg.is_integral()) { // Normalize type. - switch (spec.type) { + switch (specs.type) { case 'i': case 'u': - spec.type = 'd'; + specs.type = 'd'; break; case 'c': visit_format_arg(internal::char_converter(arg), @@ -557,7 +558,7 @@ OutputIt basic_printf_context::format() { start = it; // Format argument. - visit_format_arg(ArgFormatter(out, spec, *this), arg); + visit_format_arg(ArgFormatter(out, specs, *this), arg); } return std::copy(start, it, out); } diff --git a/test/custom-formatter-test.cc b/test/custom-formatter-test.cc index 8f3ab043..db1e199c 100644 --- a/test/custom-formatter-test.cc +++ b/test/custom-formatter-test.cc @@ -32,7 +32,7 @@ class custom_arg_formatter iterator operator()(double value) { // Comparing a float to 0.0 is safe. - if (round(value * pow(10, spec()->precision)) == 0.0) value = 0; + if (round(value * pow(10, specs()->precision)) == 0.0) value = 0; return base::operator()(value); } }; diff --git a/test/printf-test.cc b/test/printf-test.cc index 77966b5b..e2528912 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -572,8 +572,8 @@ class custom_printf_arg_formatter : public formatter_t { using formatter_t::iterator; custom_printf_arg_formatter(formatter_t::iterator iter, - formatter_t::format_specs& spec, context_t& ctx) - : formatter_t(iter, spec, ctx) {} + formatter_t::format_specs& specs, context_t& ctx) + : formatter_t(iter, specs, ctx) {} using formatter_t::operator(); @@ -584,7 +584,7 @@ class custom_printf_arg_formatter : public formatter_t { iterator operator()(double value) { #endif // Comparing a float to 0.0 is safe. - if (round(value * pow(10, spec()->precision)) == 0.0) value = 0; + if (round(value * pow(10, specs()->precision)) == 0.0) value = 0; return formatter_t::operator()(value); } }