From bc15e3700e4a74713968579e8922027314dc2914 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 7 Jul 2019 10:44:06 -0700 Subject: [PATCH] typedef -> using --- include/fmt/format.h | 49 +++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 093c63a3..dffb8b3b 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2093,8 +2093,6 @@ enum class arg_id_kind { none, index, name }; // An argument reference. template struct arg_ref { - typedef Char char_type; - FMT_CONSTEXPR arg_ref() : kind(arg_id_kind::none), val() {} FMT_CONSTEXPR explicit arg_ref(unsigned index) : kind(arg_id_kind::index), val(index) {} @@ -2133,7 +2131,7 @@ template class dynamic_specs_handler : public specs_setter { public: - typedef typename ParseContext::char_type char_type; + using char_type = typename ParseContext::char_type; FMT_CONSTEXPR dynamic_specs_handler(dynamic_format_specs& specs, ParseContext& ctx) @@ -2157,7 +2155,7 @@ class dynamic_specs_handler } private: - typedef arg_ref arg_ref_type; + using arg_ref_type = arg_ref; FMT_CONSTEXPR arg_ref_type make_arg_ref(unsigned arg_id) { context_.check_arg_id(arg_id); @@ -2493,7 +2491,7 @@ class format_string_checker { FMT_CONSTEXPR const Char* on_format_specs(const Char* begin, const Char*) { advance_to(context_, begin); - return arg_id_ < NUM_ARGS ? parse_funcs_[arg_id_](context_) : begin; + return arg_id_ < num_args ? parse_funcs_[arg_id_](context_) : begin; } FMT_CONSTEXPR void on_error(const char* message) { @@ -2501,19 +2499,19 @@ class format_string_checker { } private: - typedef basic_parse_context parse_context_type; - enum { NUM_ARGS = sizeof...(Args) }; + using parse_context_type = basic_parse_context; + enum { num_args = sizeof...(Args) }; FMT_CONSTEXPR void check_arg_id() { - if (arg_id_ >= NUM_ARGS) context_.on_error("argument index out of range"); + if (arg_id_ >= num_args) context_.on_error("argument index out of range"); } // Format specifier parsing function. - typedef const Char* (*parse_func)(parse_context_type&); + using parse_func = const Char* (*)(parse_context_type&); unsigned arg_id_; parse_context_type context_; - parse_func parse_funcs_[NUM_ARGS > 0 ? NUM_ARGS : 1]; + parse_func parse_funcs_[num_args > 0 ? num_args : 1]; }; template @@ -2527,10 +2525,10 @@ FMT_CONSTEXPR bool do_check_format_string(basic_string_view s, template ::value), int>> void check_format_string(S format_str) { - typedef typename S::char_type char_t; FMT_CONSTEXPR_DECL bool invalid_format = - internal::do_check_format_string(to_string_view(format_str)); + internal::do_check_format_string( + to_string_view(format_str)); (void)invalid_format; } @@ -2565,17 +2563,17 @@ using wwriter FMT_DEPRECATED = template class arg_formatter : public internal::arg_formatter_base { private: - typedef typename Range::value_type char_type; - typedef internal::arg_formatter_base base; - typedef basic_format_context context_type; + using char_type = typename Range::value_type; + using base = internal::arg_formatter_base; + using context_type = basic_format_context; context_type& ctx_; basic_parse_context* parse_ctx_; public: - typedef Range range; - typedef typename base::iterator iterator; - typedef typename base::format_specs format_specs; + using range = Range; + using iterator = typename base::iterator; + using format_specs = typename base::format_specs; /** \rst @@ -3026,7 +3024,7 @@ struct formatter : formatter, Char> { // A formatter for types known only at run time such as variant alternatives. // // Usage: -// typedef std::variant variant; +// using variant = std::variant; // template <> // struct formatter: dynamic_formatter<> { // void format(buffer &buf, const variant &v, context &ctx) { @@ -3074,9 +3072,8 @@ template class dynamic_formatter { } if (specs_.alt) checker.on_hash(); if (specs_.precision >= 0) checker.end_precision(); - typedef internal::output_range - range; + using range = internal::output_range; visit_format_arg(arg_formatter(ctx, nullptr, &specs_), internal::make_arg(val)); return ctx.out(); @@ -3111,7 +3108,7 @@ FMT_CONSTEXPR void advance_to(basic_parse_context& ctx, template struct format_handler : internal::error_handler { - typedef typename ArgFormatter::range range; + using range = typename ArgFormatter::range; format_handler(range r, basic_string_view str, basic_format_args format_args, @@ -3149,7 +3146,7 @@ struct format_handler : internal::error_handler { if (visit_format_arg(f, arg)) return parse_context.begin(); basic_format_specs specs; using internal::specs_handler; - typedef basic_parse_context parse_context_t; + using parse_context_t = basic_parse_context; internal::specs_checker> handler( specs_handler(specs, parse_context, context), arg.type()); @@ -3200,7 +3197,7 @@ struct formatter, Char> template auto format(const arg_join& value, FormatContext& ctx) -> decltype(ctx.out()) { - typedef formatter::value_type, Char> base; + using base = formatter::value_type, Char>; auto it = value.begin; auto out = ctx.out(); if (it != value.end) {