From 3947a7a98cdb3ec8962c53ad021129b7e72a14b8 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 29 Aug 2014 06:57:53 -0700 Subject: [PATCH] Move check_sign to anonymous namespace. --- format.cc | 29 ++++++++++++++--------------- format.h | 2 -- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/format.cc b/format.cc index 04e64bf7..673cc2a8 100644 --- a/format.cc +++ b/format.cc @@ -188,6 +188,20 @@ const Char *find_closing_brace(const Char *s, int num_open_braces = 1) { throw fmt::FormatError("unmatched '{' in format"); } +template +void check_sign(const Char *&s, const Arg &arg) { + char sign = static_cast(*s); + if (arg.type > Arg::LAST_NUMERIC_TYPE) { + throw fmt::FormatError(fmt::format( + "format specifier '{}' requires numeric argument", sign)); + } + if (arg.type == Arg::UINT || arg.type == Arg::ULONG_LONG) { + throw fmt::FormatError(fmt::format( + "format specifier '{}' requires signed argument", sign)); + } + ++s; +} + // Checks if an argument is a valid printf width specifier and sets // left alignment if it is negative. class WidthHandler : public fmt::internal::ArgVisitor { @@ -759,21 +773,6 @@ inline const Arg &fmt::BasicFormatter::parse_arg_index(const Char *&s) { return *arg; } -template -void fmt::BasicFormatter::check_sign( - const Char *&s, const Arg &arg) { - char sign = static_cast(*s); - if (arg.type > Arg::LAST_NUMERIC_TYPE) { - throw FormatError(fmt::format( - "format specifier '{}' requires numeric argument", sign)); - } - if (arg.type == Arg::UINT || arg.type == Arg::ULONG_LONG) { - throw FormatError(fmt::format( - "format specifier '{}' requires signed argument", sign)); - } - ++s; -} - const Arg *fmt::internal::FormatterBase::next_arg(const char *&error) { if (next_arg_index_ < 0) { error = "cannot switch from manual to automatic argument indexing"; diff --git a/format.h b/format.h index 69acecd3..6ee80112 100644 --- a/format.h +++ b/format.h @@ -889,8 +889,6 @@ private: // Parses argument index and returns corresponding argument. const internal::Arg &parse_arg_index(const Char *&s); - void check_sign(const Char *&s, const internal::Arg &arg); - public: explicit BasicFormatter(BasicWriter &w) : writer_(w) {}