From 939aff29361e63ca4858e6a6319471f24d979aa2 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 30 Dec 2016 10:19:38 -0800 Subject: [PATCH] Remove unnecessary template arg from basic_format_args --- fmt/format.h | 29 ++++++++++++++--------------- fmt/printf.h | 11 +++++------ test/custom-formatter-test.cc | 2 +- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/fmt/format.h b/fmt/format.h index a67aa340..6f9007dd 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -1327,7 +1327,7 @@ basic_format_arg make_arg(const T &value); struct monostate {}; -template +template class basic_format_args; // A formatting argument. It is a trivially copyable/constructible type to @@ -1345,7 +1345,7 @@ class basic_format_arg { friend typename std::result_of::type visit(Visitor &&vis, basic_format_arg arg); - friend class basic_format_args; + friend class basic_format_args; friend class internal::ArgMap; public: @@ -1553,7 +1553,7 @@ inline format_arg_store } /** Formatting arguments. */ -template +template class basic_format_args { public: typedef unsigned size_type; @@ -1626,8 +1626,8 @@ class basic_format_args { } }; -typedef basic_format_args, char> format_args; -typedef basic_format_args, wchar_t> wformat_args; +typedef basic_format_args format_args; +typedef basic_format_args wformat_args; enum Alignment { ALIGN_DEFAULT, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, ALIGN_NUMERIC @@ -1863,7 +1863,7 @@ class ArgMap { MapType map_; public: - void init(const basic_format_args &args); + void init(const basic_format_args &args); const basic_format_arg *find(const fmt::BasicStringRef &name) const { @@ -1878,7 +1878,7 @@ class ArgMap { }; template -void ArgMap::init(const basic_format_args &args) { +void ArgMap::init(const basic_format_args &args) { if (!map_.empty()) return; typedef internal::NamedArg NamedArg; @@ -2050,18 +2050,17 @@ template class format_context_base { private: const Char *ptr_; - basic_format_args args_; + basic_format_args args_; int next_arg_index_; protected: typedef basic_format_arg format_arg; - format_context_base(const Char *format_str, - basic_format_args args) + format_context_base(const Char *format_str, basic_format_args args) : ptr_(format_str), args_(args), next_arg_index_(0) {} ~format_context_base() {} - basic_format_args args() const { return args_; } + basic_format_args args() const { return args_; } // Returns the argument with specified index. format_arg do_get_arg(unsigned arg_index, const char *&error) { @@ -2157,7 +2156,7 @@ class basic_format_context : \endrst */ basic_format_context(const Char *format_str, - basic_format_args args) + basic_format_args args) : Base(format_str, args) {} // Parses argument id and returns corresponding argument. @@ -2394,7 +2393,7 @@ class BasicWriter { } void vwrite(BasicCStringRef format, - basic_format_args, Char> args); + basic_format_args> args); /** \rst Writes formatted data. @@ -3578,7 +3577,7 @@ void do_format_arg(BasicWriter &writer, basic_format_arg arg, /** Formats arguments and writes the output to the writer. */ template void vformat(BasicWriter &writer, BasicCStringRef format_str, - basic_format_args args) { + basic_format_args args) { basic_format_context ctx(format_str.c_str(), args); const Char *&s = ctx.ptr(); const Char *start = s; @@ -3604,7 +3603,7 @@ void vformat(BasicWriter &writer, BasicCStringRef format_str, template inline void BasicWriter::vwrite( BasicCStringRef format, - basic_format_args, Char> args) { + basic_format_args> args) { vformat>(*this, format, args); } } // namespace fmt diff --git a/fmt/printf.h b/fmt/printf.h index 13b82afd..beea7c39 100644 --- a/fmt/printf.h +++ b/fmt/printf.h @@ -282,7 +282,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase { /** Formats an argument of a custom (user-defined) type. */ void operator()(internal::CustomValue c) { const Char format_str[] = {'}', '\0'}; - auto args = basic_format_args, Char>(); + auto args = basic_format_args>(); basic_format_context ctx(format_str, args); c.format(this->writer(), c.value, &ctx); } @@ -322,7 +322,7 @@ class printf_context : \endrst */ explicit printf_context(BasicCStringRef format_str, - basic_format_args args) + basic_format_args args) : Base(format_str.c_str(), args) {} /** Formats stored arguments and writes the output to the writer. */ @@ -510,11 +510,11 @@ void format_value(BasicWriter &w, const T &value, template void printf(BasicWriter &w, BasicCStringRef format, - basic_format_args, Char> args) { + basic_format_args> args) { printf_context(format, args).format(w); } -typedef basic_format_args, char> printf_args; +typedef basic_format_args> printf_args; inline std::string vsprintf(CStringRef format, printf_args args) { MemoryWriter w; @@ -537,8 +537,7 @@ inline std::string sprintf(CStringRef format_str, const Args & ... args) { } inline std::wstring vsprintf( - WCStringRef format, - basic_format_args, wchar_t> args) { + WCStringRef format, basic_format_args> args) { WMemoryWriter w; printf(w, format, args); return w.str(); diff --git a/test/custom-formatter-test.cc b/test/custom-formatter-test.cc index 51bed768..7601aeb5 100644 --- a/test/custom-formatter-test.cc +++ b/test/custom-formatter-test.cc @@ -63,7 +63,7 @@ typedef fmt::printf_context std::string custom_vsprintf( const char* format_str, - fmt::basic_format_args args) { + fmt::basic_format_args args) { fmt::MemoryWriter writer; CustomPrintfFormatter formatter(format_str, args); formatter.format(writer);