diff --git a/include/fmt/format.h b/include/fmt/format.h index 75333ef8..093c63a3 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1834,7 +1834,7 @@ FMT_CONSTEXPR unsigned parse_nonnegative_int(const Char*& begin, template class custom_formatter { private: - typedef typename Context::char_type char_type; + using char_type = typename Context::char_type; basic_parse_context& parse_ctx_; Context& ctx_; @@ -1852,12 +1852,11 @@ template class custom_formatter { template bool operator()(T) const { return false; } }; -template struct is_integer { - enum { - value = std::is_integral::value && !std::is_same::value && - !std::is_same::value && !std::is_same::value - }; -}; +template +using is_integer = + bool_constant::value && !std::is_same::value && + !std::is_same::value && + !std::is_same::value>; template class width_checker { public: @@ -2031,7 +2030,7 @@ FMT_CONSTEXPR typename Context::format_arg get_arg(Context& ctx, unsigned id) { template class specs_handler : public specs_setter { public: - typedef typename Context::char_type char_type; + using char_type = typename Context::char_type; FMT_CONSTEXPR specs_handler(basic_format_specs& specs, ParseContext& parse_ctx, Context& ctx) @@ -2053,7 +2052,7 @@ class specs_handler : public specs_setter { private: // This is only needed for compatibility with gcc 4.4. - typedef typename Context::format_arg format_arg; + using format_arg = typename Context::format_arg; FMT_CONSTEXPR format_arg get_arg(auto_id) { return internal::get_arg(context_, parse_context_.next_arg_id()); @@ -2090,23 +2089,25 @@ struct string_view_metadata { std::size_t size_; }; +enum class arg_id_kind { none, index, name }; + // An argument reference. template struct arg_ref { - enum Kind { NONE, INDEX, NAME }; typedef Char char_type; - FMT_CONSTEXPR arg_ref() : kind(NONE), val() {} - FMT_CONSTEXPR explicit arg_ref(unsigned index) : kind(INDEX), val(index) {} + FMT_CONSTEXPR arg_ref() : kind(arg_id_kind::none), val() {} + FMT_CONSTEXPR explicit arg_ref(unsigned index) + : kind(arg_id_kind::index), val(index) {} FMT_CONSTEXPR explicit arg_ref(string_view_metadata name) - : kind(NAME), val(name) {} + : kind(arg_id_kind::name), val(name) {} FMT_CONSTEXPR arg_ref& operator=(unsigned idx) { - kind = INDEX; + kind = arg_id_kind::index; val.index = idx; return *this; } - Kind kind; + arg_id_kind kind; union value { FMT_CONSTEXPR value() : index(0u) {} FMT_CONSTEXPR value(unsigned id) : index(id) {} @@ -2537,19 +2538,19 @@ template