diff --git a/include/fmt/core.h b/include/fmt/core.h index 96ec79d1..ea3bf969 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -642,7 +642,7 @@ typed_value } // Maximum number of arguments with packed types. -enum { MAX_PACKED_ARGS = 15 }; +enum { max_packed_args = 15 }; template class arg_map; @@ -912,8 +912,7 @@ typedef buffer_context::type wcontext; namespace internal { template -class get_type { - public: +struct get_type { typedef decltype(make_value( declval::type&>())) value_type; static const type value = value_type::type_tag; @@ -954,7 +953,7 @@ class arg_store { static const size_t NUM_ARGS = sizeof...(Args); // Packed is a macro on MinGW so use IS_PACKED instead. - static const bool IS_PACKED = NUM_ARGS < internal::MAX_PACKED_ARGS; + static const bool IS_PACKED = NUM_ARGS < internal::max_packed_args; typedef typename std::conditional< IS_PACKED, internal::value, basic_arg>::type value_type; @@ -1004,10 +1003,10 @@ class basic_format_args { private: // To reduce compiled code size per formatting function call, types of first - // MAX_PACKED_ARGS arguments are passed in the types_ field. + // max_packed_args arguments are passed in the types_ field. uint64_t types_; union { - // If the number of arguments is less than MAX_PACKED_ARGS, the argument + // If the number of arguments is less than max_packed_args, the argument // values are stored in values_, otherwise they are stored in args_. // This is done to reduce compiled code size as storing larger objects // may require more code (at least on x86-64) even if the same amount of @@ -1035,7 +1034,7 @@ class basic_format_args { return index < num_args ? args_[index] : format_arg(); } format_arg arg; - if (index > internal::MAX_PACKED_ARGS) + if (index > internal::max_packed_args) return arg; arg.type_ = type(index); if (arg.type_ == internal::none_type) @@ -1064,7 +1063,7 @@ class basic_format_args { unsigned max_size() const { int64_t signed_types = static_cast(types_); return signed_types < 0 ? - -signed_types : static_cast(internal::MAX_PACKED_ARGS); + -signed_types : static_cast(internal::max_packed_args); } }; @@ -1127,7 +1126,7 @@ inline internal::named_arg arg(wstring_view name, const T &arg) { template void arg(S, internal::named_arg) FMT_DELETED; -enum color { BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE }; +enum color { black, red, green, yellow, blue, magenta, cyan, white }; FMT_API void vprint_colored(color c, string_view format, format_args args); diff --git a/include/fmt/format.h b/include/fmt/format.h index 57f1867e..2cb7e828 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1326,7 +1326,7 @@ void arg_map::init(const basic_format_args &args) { if (map_) return; map_ = new entry[args.max_size()]; - bool use_values = args.type(MAX_PACKED_ARGS - 1) == internal::none_type; + bool use_values = args.type(max_packed_args - 1) == internal::none_type; if (use_values) { for (unsigned i = 0;/*nothing*/; ++i) { internal::type arg_type = args.type(i); @@ -1342,11 +1342,11 @@ void arg_map::init(const basic_format_args &args) { } return; } - for (unsigned i = 0; i != MAX_PACKED_ARGS; ++i) { + for (unsigned i = 0; i != max_packed_args; ++i) { if (args.type(i) == internal::name_arg_type) push_back(args.args_[i].value_); } - for (unsigned i = MAX_PACKED_ARGS; ; ++i) { + for (unsigned i = max_packed_args; ; ++i) { switch (args.args_[i].type_) { case internal::none_type: return; diff --git a/test/format-test.cc b/test/format-test.cc index fcf2322f..62bf224e 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -442,9 +442,9 @@ TEST(FormatterTest, ManyArgs) { format_error, "argument index out of range"); EXPECT_THROW_MSG(TestFormat<21>::format("{21}"), format_error, "argument index out of range"); - enum { MAX_PACKED_ARGS = fmt::internal::MAX_PACKED_ARGS }; - std::string format_str = fmt::format("{{{}}}", MAX_PACKED_ARGS + 1); - EXPECT_THROW_MSG(TestFormat::format(format_str), + enum { max_packed_args = fmt::internal::max_packed_args }; + std::string format_str = fmt::format("{{{}}}", max_packed_args + 1); + EXPECT_THROW_MSG(TestFormat::format(format_str), format_error, "argument index out of range"); } @@ -1405,7 +1405,7 @@ TEST(FormatTest, Print) { #if FMT_USE_FILE_DESCRIPTORS TEST(FormatTest, PrintColored) { - EXPECT_WRITE(stdout, fmt::print_colored(fmt::RED, "Hello, {}!\n", "world"), + EXPECT_WRITE(stdout, fmt::print_colored(fmt::red, "Hello, {}!\n", "world"), "\x1b[31mHello, world!\n\x1b[0m"); } #endif