diff --git a/fmt/format.cc b/fmt/format.cc index 5ec8e41b..499e8382 100644 --- a/fmt/format.cc +++ b/fmt/format.cc @@ -51,8 +51,6 @@ # endif #endif -using fmt::internal::Arg; - #if FMT_EXCEPTIONS # define FMT_TRY try # define FMT_CATCH(x) catch (x) diff --git a/fmt/format.h b/fmt/format.h index bed2a706..e03c66aa 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -1039,8 +1039,6 @@ struct format_arg : internal::Value { namespace internal { -typedef format_arg Arg; - template struct NamedArg; @@ -1180,61 +1178,80 @@ typedef Value::Type Type; template constexpr Type gettype() { + typedef format_arg Arg; return IsNamedArg::value ? Arg::NAMED_ARG : (ConvertToInt::value ? Arg::INT : Arg::CUSTOM); } -template <> constexpr Type gettype() { return Arg::BOOL; } -template <> constexpr Type gettype() { return Arg::INT; } -template <> constexpr Type gettype() { return Arg::UINT; } -template <> constexpr Type gettype() { return Arg::INT; } -template <> constexpr Type gettype() { return Arg::UINT; } +template <> constexpr Type gettype() { return format_arg::BOOL; } +template <> constexpr Type gettype() { return format_arg::INT; } +template <> constexpr Type gettype() { + return format_arg::UINT; +} +template <> constexpr Type gettype() { return format_arg::INT; } +template <> constexpr Type gettype() { return format_arg::UINT; } template <> constexpr Type gettype() { - return sizeof(long) == sizeof(int) ? Arg::INT : Arg::LONG_LONG; + return sizeof(long) == sizeof(int) ? format_arg::INT : format_arg::LONG_LONG; } template <> constexpr Type gettype() { return sizeof(unsigned long) == sizeof(unsigned) ? - Arg::UINT : Arg::ULONG_LONG; + format_arg::UINT : format_arg::ULONG_LONG; } -template <> constexpr Type gettype() { return Arg::LONG_LONG; } -template <> constexpr Type gettype() { return Arg::ULONG_LONG; } -template <> constexpr Type gettype() { return Arg::DOUBLE; } -template <> constexpr Type gettype() { return Arg::DOUBLE; } -template <> constexpr Type gettype() { return Arg::LONG_DOUBLE; } -template <> constexpr Type gettype() { return Arg::INT; } -template <> constexpr Type gettype() { return Arg::UINT; } -template <> constexpr Type gettype() { return Arg::CHAR; } +template <> constexpr Type gettype() { return format_arg::LONG_LONG; } +template <> constexpr Type gettype() { + return format_arg::ULONG_LONG; +} +template <> constexpr Type gettype() { return format_arg::DOUBLE; } +template <> constexpr Type gettype() { return format_arg::DOUBLE; } +template <> constexpr Type gettype() { + return format_arg::LONG_DOUBLE; +} +template <> constexpr Type gettype() { return format_arg::INT; } +template <> constexpr Type gettype() { return format_arg::UINT; } +template <> constexpr Type gettype() { return format_arg::CHAR; } #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) -template <> constexpr Type gettype() { return Arg::CHAR; } +template <> constexpr Type gettype() { return format_arg::CHAR; } #endif -template <> constexpr Type gettype() { return Arg::CSTRING; } -template <> constexpr Type gettype() { return Arg::CSTRING; } -template <> constexpr Type gettype() { return Arg::CSTRING; } +template <> constexpr Type gettype() { return format_arg::CSTRING; } +template <> constexpr Type gettype() { + return format_arg::CSTRING; +} +template <> constexpr Type gettype() { + return format_arg::CSTRING; +} template <> constexpr Type gettype() { - return Arg::CSTRING; + return format_arg::CSTRING; +} +template <> constexpr Type gettype() { + return format_arg::CSTRING; } -template <> constexpr Type gettype() { return Arg::CSTRING; } template <> constexpr Type gettype() { - return Arg::CSTRING; + return format_arg::CSTRING; +} +template <> constexpr Type gettype() { return format_arg::STRING; } +template <> constexpr Type gettype() { return format_arg::STRING; } +template <> constexpr Type gettype() { return format_arg::CSTRING; } +template <> constexpr Type gettype() { return format_arg::WSTRING; } +template <> constexpr Type gettype() { + return format_arg::WSTRING; +} +template <> constexpr Type gettype() { + return format_arg::WSTRING; +} +template <> constexpr Type gettype() { return format_arg::WSTRING; } +template <> constexpr Type gettype() { return format_arg::POINTER; } +template <> constexpr Type gettype() { + return format_arg::POINTER; } -template <> constexpr Type gettype() { return Arg::STRING; } -template <> constexpr Type gettype() { return Arg::STRING; } -template <> constexpr Type gettype() { return Arg::CSTRING; } -template <> constexpr Type gettype() { return Arg::WSTRING; } -template <> constexpr Type gettype() { return Arg::WSTRING; } -template <> constexpr Type gettype() { return Arg::WSTRING; } -template <> constexpr Type gettype() { return Arg::WSTRING; } -template <> constexpr Type gettype() { return Arg::POINTER; } -template <> constexpr Type gettype() { return Arg::POINTER; } template constexpr Type type() { return gettype::type>(); } -// Makes an Arg object from any type. +// Makes a format_arg object from any type. template -class MakeValue : public Arg { +class MakeValue : public format_arg { public: typedef typename Context::char_type Char; @@ -1387,27 +1404,27 @@ class MakeValue : public Arg { } }; -template -class MakeArg : public Arg { +template +class MakeArg : public format_arg { public: MakeArg() { - type = Arg::NONE; + type = format_arg::NONE; } template MakeArg(const T &value) - : Arg(MakeValue(value)) { + : format_arg(MakeValue(value)) { type = internal::type(); } }; template -struct NamedArg : Arg { +struct NamedArg : format_arg { BasicStringRef name; template NamedArg(BasicStringRef argname, const T &value) - : Arg(MakeArg< basic_format_context >(value)), name(argname) {} + : format_arg(MakeArg< basic_format_context >(value)), name(argname) {} }; class RuntimeError : public std::runtime_error { @@ -1438,7 +1455,7 @@ class format_arg_store { static const bool IS_PACKED = NUM_ARGS <= internal::MAX_PACKED_ARGS; typedef typename std::conditional< - IS_PACKED, internal::Value, internal::Arg>::type value_type; + IS_PACKED, internal::Value, format_arg>::type value_type; // If the arguments are not packed, add one more element to mark the end. std::array data_; @@ -1805,7 +1822,7 @@ template class ArgMap { private: typedef std::vector< - std::pair, internal::Arg> > MapType; + std::pair, format_arg> > MapType; typedef typename MapType::value_type Pair; MapType map_; @@ -1814,7 +1831,7 @@ class ArgMap { template void init(const basic_format_args &args); - const internal::Arg* find(const fmt::BasicStringRef &name) const { + const format_arg *find(const fmt::BasicStringRef &name) const { // The list is unsorted, so just return the first matching name. for (typename MapType::const_iterator it = map_.begin(), end = map_.end(); it != end; ++it) { @@ -1833,14 +1850,14 @@ void ArgMap::init(const basic_format_args &args) { typedef internal::NamedArg NamedArg; const NamedArg *named_arg = 0; bool use_values = - args.type(MAX_PACKED_ARGS - 1) == internal::Arg::NONE; + args.type(MAX_PACKED_ARGS - 1) == format_arg::NONE; if (use_values) { for (unsigned i = 0;/*nothing*/; ++i) { - internal::Arg::Type arg_type = args.type(i); + format_arg::Type arg_type = args.type(i); switch (arg_type) { - case internal::Arg::NONE: + case format_arg::NONE: return; - case internal::Arg::NAMED_ARG: + case format_arg::NAMED_ARG: named_arg = static_cast(args.values_[i].pointer); map_.push_back(Pair(named_arg->name, *named_arg)); break; @@ -1851,17 +1868,17 @@ void ArgMap::init(const basic_format_args &args) { return; } for (unsigned i = 0; i != MAX_PACKED_ARGS; ++i) { - internal::Arg::Type arg_type = args.type(i); - if (arg_type == internal::Arg::NAMED_ARG) { + format_arg::Type arg_type = args.type(i); + if (arg_type == format_arg::NAMED_ARG) { named_arg = static_cast(args.args_[i].pointer); map_.push_back(Pair(named_arg->name, *named_arg)); } } for (unsigned i = MAX_PACKED_ARGS;/*nothing*/; ++i) { switch (args.args_[i].type) { - case internal::Arg::NONE: + case format_arg::NONE: return; - case internal::Arg::NAMED_ARG: + case format_arg::NAMED_ARG: named_arg = static_cast(args.args_[i].pointer); map_.push_back(Pair(named_arg->name, *named_arg)); break; @@ -1886,18 +1903,18 @@ class ArgFormatterBase { } template - void write_str(Arg::StringValue value, - typename EnableIf< - std::is_same::value && - std::is_same::value, int>::type = 0) { + void write_str(format_arg::StringValue value, + typename EnableIf< + std::is_same::value && + std::is_same::value, int>::type = 0) { writer_.write_str(value, spec_); } template - void write_str(Arg::StringValue value, - typename EnableIf< - !std::is_same::value || - !std::is_same::value, int>::type = 0) { + void write_str(format_arg::StringValue value, + typename EnableIf< + !std::is_same::value || + !std::is_same::value, int>::type = 0) { // Do nothing. } @@ -1907,12 +1924,14 @@ class ArgFormatterBase { void write(bool value) { const char *str_value = value ? "true" : "false"; - Arg::StringValue str = { str_value, std::strlen(str_value) }; + format_arg::StringValue str = { str_value, std::strlen(str_value) }; writer_.write_str(str, spec_); } void write(const char *value) { - Arg::StringValue str = {value, value != 0 ? std::strlen(value) : 0}; + format_arg::StringValue str = { + value, value != 0 ? std::strlen(value) : 0 + }; writer_.write_str(str, spec_); } @@ -1972,11 +1991,11 @@ class ArgFormatterBase { write(value); } - void operator()(Arg::StringValue value) { + void operator()(format_arg::StringValue value) { writer_.write_str(value, spec_); } - void operator()(Arg::StringValue value) { + void operator()(format_arg::StringValue value) { write_str(value); } @@ -2273,7 +2292,7 @@ class BasicWriter { CharPtr write_str(const StrChar *s, std::size_t size, const AlignSpec &spec); template - void write_str(const internal::Arg::StringValue &str, + void write_str(const format_arg::StringValue &str, const FormatSpec &spec); // This following methods are private to disallow writing wide characters @@ -2497,7 +2516,7 @@ typename BasicWriter::CharPtr BasicWriter::write_str( template template void BasicWriter::write_str( - const internal::Arg::StringValue &s, const FormatSpec &spec) { + const format_arg::StringValue &s, const FormatSpec &spec) { // Check if StrChar is convertible to Char. internal::CharTraits::convert(StrChar()); if (spec.type_ && spec.type_ != 's') @@ -3262,8 +3281,8 @@ unsigned parse_nonnegative_int(const Char *&s) { return value; } -inline void require_numeric_argument(const Arg &arg, char spec) { - if (arg.type > Arg::LAST_NUMERIC_TYPE) { +inline void require_numeric_argument(const format_arg &arg, char spec) { + if (arg.type > format_arg::LAST_NUMERIC_TYPE) { std::string message = fmt::format("format specifier '{}' requires numeric argument", spec); FMT_THROW(fmt::format_error(message)); @@ -3271,10 +3290,10 @@ inline void require_numeric_argument(const Arg &arg, char spec) { } template -void check_sign(const Char *&s, const Arg &arg) { +void check_sign(const Char *&s, const format_arg &arg) { char sign = static_cast(*s); require_numeric_argument(arg, sign); - if (arg.type == Arg::UINT || arg.type == Arg::ULONG_LONG) { + if (arg.type == format_arg::UINT || arg.type == format_arg::ULONG_LONG) { FMT_THROW(format_error(fmt::format( "format specifier '{}' requires signed argument", sign))); } @@ -3287,7 +3306,7 @@ inline format_arg basic_format_context::get_arg( BasicStringRef name, const char *&error) { if (this->check_no_auto_index(error)) { map_.init(this->args()); - const internal::Arg *arg = map_.find(name); + const format_arg *arg = map_.find(name); if (arg) return *arg; error = "argument not found"; @@ -3322,13 +3341,12 @@ inline format_arg basic_format_context::parse_arg_id() { // Formats a single argument. template -void do_format_arg(BasicWriter &writer, const internal::Arg &arg, +void do_format_arg(BasicWriter &writer, const format_arg &arg, Context &ctx) { - using internal::Arg; const Char *&s = ctx.ptr(); FormatSpec spec; if (*s == ':') { - if (arg.type == Arg::CUSTOM) { + if (arg.type == format_arg::CUSTOM) { arg.custom.format(&writer, arg.custom.value, &ctx); return; } @@ -3402,25 +3420,25 @@ void do_format_arg(BasicWriter &writer, const internal::Arg &arg, spec.width_ = internal::parse_nonnegative_int(s); } else if (*s == '{') { ++s; - Arg width_arg = ctx.parse_arg_id(); + format_arg width_arg = ctx.parse_arg_id(); if (*s++ != '}') FMT_THROW(format_error("invalid format string")); ULongLong value = 0; switch (width_arg.type) { - case Arg::INT: + case format_arg::INT: if (width_arg.int_value < 0) FMT_THROW(format_error("negative width")); value = width_arg.int_value; break; - case Arg::UINT: + case format_arg::UINT: value = width_arg.uint_value; break; - case Arg::LONG_LONG: + case format_arg::LONG_LONG: if (width_arg.long_long_value < 0) FMT_THROW(format_error("negative width")); value = width_arg.long_long_value; break; - case Arg::ULONG_LONG: + case format_arg::ULONG_LONG: value = width_arg.ulong_long_value; break; default: @@ -3439,25 +3457,25 @@ void do_format_arg(BasicWriter &writer, const internal::Arg &arg, spec.precision_ = internal::parse_nonnegative_int(s); } else if (*s == '{') { ++s; - Arg precision_arg = ctx.parse_arg_id(); + format_arg precision_arg = ctx.parse_arg_id(); if (*s++ != '}') FMT_THROW(format_error("invalid format string")); ULongLong value = 0; switch (precision_arg.type) { - case Arg::INT: + case format_arg::INT: if (precision_arg.int_value < 0) FMT_THROW(format_error("negative precision")); value = precision_arg.int_value; break; - case Arg::UINT: + case format_arg::UINT: value = precision_arg.uint_value; break; - case Arg::LONG_LONG: + case format_arg::LONG_LONG: if (precision_arg.long_long_value < 0) FMT_THROW(format_error("negative precision")); value = precision_arg.long_long_value; break; - case Arg::ULONG_LONG: + case format_arg::ULONG_LONG: value = precision_arg.ulong_long_value; break; default: @@ -3469,10 +3487,11 @@ void do_format_arg(BasicWriter &writer, const internal::Arg &arg, } else { FMT_THROW(format_error("missing precision specifier")); } - if (arg.type <= Arg::LAST_INTEGER_TYPE || arg.type == Arg::POINTER) { + if (arg.type <= format_arg::LAST_INTEGER_TYPE || + arg.type == format_arg::POINTER) { FMT_THROW(format_error( fmt::format("precision not allowed in {} format specifier", - arg.type == Arg::POINTER ? "pointer" : "integer"))); + arg.type == format_arg::POINTER ? "pointer" : "integer"))); } } diff --git a/fmt/printf.h b/fmt/printf.h index 30b80953..386acf98 100644 --- a/fmt/printf.h +++ b/fmt/printf.h @@ -83,11 +83,11 @@ struct is_same { template class ArgConverter { private: - internal::Arg &arg_; + format_arg &arg_; wchar_t type_; public: - ArgConverter(internal::Arg &arg, wchar_t type) + ArgConverter(format_arg &arg, wchar_t type) : arg_(arg), type_(type) {} void operator()(bool value) { @@ -99,28 +99,27 @@ class ArgConverter { typename std::enable_if::value>::type operator()(U value) { bool is_signed = type_ == 'd' || type_ == 'i'; - using internal::Arg; typedef typename internal::Conditional< is_same::value, U, T>::type TargetType; if (sizeof(TargetType) <= sizeof(int)) { // Extra casts are used to silence warnings. if (is_signed) { - arg_.type = Arg::INT; + arg_.type = format_arg::INT; arg_.int_value = static_cast(static_cast(value)); } else { - arg_.type = Arg::UINT; + arg_.type = format_arg::UINT; typedef typename internal::MakeUnsigned::Type Unsigned; arg_.uint_value = static_cast(static_cast(value)); } } else { if (is_signed) { - arg_.type = Arg::LONG_LONG; + arg_.type = format_arg::LONG_LONG; // glibc's printf doesn't sign extend arguments of smaller types: // std::printf("%lld", -42); // prints "4294967254" // but we don't have to do the same because it's a UB. arg_.long_long_value = static_cast(value); } else { - arg_.type = Arg::ULONG_LONG; + arg_.type = format_arg::ULONG_LONG; arg_.ulong_long_value = static_cast::Type>(value); } @@ -146,17 +145,17 @@ void convert_arg(format_arg &arg, wchar_t type) { // Converts an integer argument to char for printf. class CharConverter { private: - internal::Arg &arg_; + format_arg &arg_; FMT_DISALLOW_COPY_AND_ASSIGN(CharConverter); public: - explicit CharConverter(internal::Arg &arg) : arg_(arg) {} + explicit CharConverter(format_arg &arg) : arg_(arg) {} template typename std::enable_if::value>::type operator()(T value) { - arg_.type = internal::Arg::CHAR; + arg_.type = format_arg::CHAR; arg_.int_value = static_cast(value); } @@ -281,7 +280,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase { } /** Formats an argument of a custom (user-defined) type. */ - void operator()(internal::Arg::CustomValue c) { + void operator()(format_arg::CustomValue c) { const Char format_str[] = {'}', '\0'}; auto args = basic_format_args>(); basic_format_context ctx(format_str, args); @@ -306,7 +305,7 @@ class printf_context : // Returns the argument with specified index or, if arg_index is equal // to the maximum unsigned value, the next argument. - internal::Arg get_arg( + format_arg get_arg( const Char *s, unsigned arg_index = (std::numeric_limits::max)()); @@ -356,11 +355,11 @@ void printf_context::parse_flags(FormatSpec &spec, const Char *&s) { } template -internal::Arg printf_context::get_arg(const Char *s, - unsigned arg_index) { +format_arg printf_context::get_arg(const Char *s, + unsigned arg_index) { (void)s; const char *error = 0; - internal::Arg arg = arg_index == std::numeric_limits::max() ? + format_arg arg = arg_index == std::numeric_limits::max() ? this->next_arg(error) : Base::get_arg(arg_index - 1, error); if (error) FMT_THROW(format_error(!*s ? "invalid format string" : error)); @@ -432,12 +431,11 @@ void printf_context::format(BasicWriter &writer) { } } - using internal::Arg; - Arg arg = get_arg(s, arg_index); + format_arg arg = get_arg(s, arg_index); if (spec.flag(HASH_FLAG) && visit(internal::IsZeroInt(), arg)) spec.flags_ &= ~internal::to_unsigned(HASH_FLAG); if (spec.fill_ == '0') { - if (arg.type <= Arg::LAST_NUMERIC_TYPE) + if (arg.type <= format_arg::LAST_NUMERIC_TYPE) spec.align_ = ALIGN_NUMERIC; else spec.fill_ = ' '; // Ignore '0' flag for non-numeric types. @@ -480,7 +478,7 @@ void printf_context::format(BasicWriter &writer) { if (!*s) FMT_THROW(format_error("invalid format string")); spec.type_ = static_cast(*s++); - if (arg.type <= Arg::LAST_INTEGER_TYPE) { + if (arg.type <= format_arg::LAST_INTEGER_TYPE) { // Normalize type. switch (spec.type_) { case 'i': case 'u': diff --git a/test/format-impl-test.cc b/test/format-impl-test.cc index 4ad2bccf..c63b6b97 100644 --- a/test/format-impl-test.cc +++ b/test/format-impl-test.cc @@ -42,12 +42,12 @@ #undef max TEST(FormatTest, ArgConverter) { - using fmt::internal::Arg; - Arg arg = Arg(); - arg.type = Arg::LONG_LONG; + using fmt::format_arg; + format_arg arg = format_arg(); + arg.type = format_arg::LONG_LONG; arg.long_long_value = std::numeric_limits::max(); visit(fmt::internal::ArgConverter(arg, 'd'), arg); - EXPECT_EQ(Arg::LONG_LONG, arg.type); + EXPECT_EQ(format_arg::LONG_LONG, arg.type); } TEST(FormatTest, FormatNegativeNaN) { diff --git a/test/util-test.cc b/test/util-test.cc index 2b144b95..3371ef20 100644 --- a/test/util-test.cc +++ b/test/util-test.cc @@ -51,9 +51,9 @@ #undef max -using fmt::StringRef; -using fmt::internal::Arg; +using fmt::format_arg; using fmt::Buffer; +using fmt::StringRef; using fmt::internal::MemoryBuffer; using testing::Return; @@ -70,9 +70,9 @@ void format_value(fmt::BasicWriter &w, Test, } template -Arg make_arg(const T &value) { +format_arg make_arg(const T &value) { typedef fmt::internal::MakeValue< fmt::basic_format_context > MakeValue; - Arg arg = MakeValue(value); + format_arg arg = MakeValue(value); arg.type = fmt::internal::type(); return arg; } @@ -406,13 +406,13 @@ TEST(UtilTest, Increment) { EXPECT_STREQ("200", s); } -template +template struct ArgInfo; #define ARG_INFO(type_code, Type, field) \ template <> \ - struct ArgInfo { \ - static Type get(const Arg &arg) { return arg.field; } \ + struct ArgInfo { \ + static Type get(const format_arg &arg) { return arg.field; } \ } ARG_INFO(INT, int, int_value); @@ -427,12 +427,12 @@ ARG_INFO(CSTRING, const char *, string.value); ARG_INFO(STRING, const char *, string.value); ARG_INFO(WSTRING, const wchar_t *, wstring.value); ARG_INFO(POINTER, const void *, pointer); -ARG_INFO(CUSTOM, Arg::CustomValue, custom); +ARG_INFO(CUSTOM, format_arg::CustomValue, custom); #define CHECK_ARG_INFO(Type, field, value) { \ - Arg arg = Arg(); \ + format_arg arg = format_arg(); \ arg.field = value; \ - EXPECT_EQ(value, ArgInfo::get(arg)); \ + EXPECT_EQ(value, ArgInfo::get(arg)); \ } TEST(ArgTest, ArgInfo) { @@ -449,17 +449,17 @@ TEST(ArgTest, ArgInfo) { CHECK_ARG_INFO(WSTRING, wstring.value, WSTR); int p = 0; CHECK_ARG_INFO(POINTER, pointer, &p); - Arg arg = Arg(); + format_arg arg = format_arg(); arg.custom.value = &p; - EXPECT_EQ(&p, ArgInfo::get(arg).value); + EXPECT_EQ(&p, ArgInfo::get(arg).value); } #define EXPECT_ARG_(Char, type_code, MakeArgType, ExpectedType, value) { \ MakeArgType input = static_cast(value); \ - Arg arg = make_arg(input); \ - EXPECT_EQ(Arg::type_code, arg.type); \ + format_arg arg = make_arg(input); \ + EXPECT_EQ(format_arg::type_code, arg.type); \ ExpectedType expected_value = static_cast(value); \ - EXPECT_EQ(expected_value, ArgInfo::get(arg)); \ + EXPECT_EQ(expected_value, ArgInfo::get(arg)); \ } #define EXPECT_ARG(type_code, Type, value) \ @@ -563,8 +563,8 @@ TEST(ArgTest, MakeArg) { EXPECT_ARG(POINTER, const void*, &n); ::Test t; - Arg arg = make_arg(t); - EXPECT_EQ(fmt::internal::Arg::CUSTOM, arg.type); + format_arg arg = make_arg(t); + EXPECT_EQ(format_arg::CUSTOM, arg.type); EXPECT_EQ(&t, arg.custom.value); fmt::MemoryWriter w; fmt::format_context ctx("}", fmt::format_args()); @@ -574,7 +574,7 @@ TEST(ArgTest, MakeArg) { TEST(UtilTest, FormatArgs) { fmt::format_args args; - EXPECT_EQ(Arg::NONE, args[1].type); + EXPECT_EQ(format_arg::NONE, args[1].type); } struct CustomFormatter { @@ -588,7 +588,7 @@ void format_value(fmt::Writer &, const Test &, CustomFormatter &ctx) { TEST(UtilTest, MakeValueWithCustomFormatter) { ::Test t; - Arg arg = fmt::internal::MakeValue(t); + format_arg arg = fmt::internal::MakeValue(t); CustomFormatter ctx = {false}; fmt::MemoryWriter w; arg.custom.format(&w, &t, &ctx); @@ -596,7 +596,7 @@ TEST(UtilTest, MakeValueWithCustomFormatter) { } struct Result { - Arg arg; + format_arg arg; Result() : arg(make_arg(0xdeadbeef)) {} @@ -627,10 +627,10 @@ struct TestVisitor { }; #define EXPECT_RESULT_(Char, type_code, value) { \ - Arg arg = make_arg(value); \ + format_arg arg = make_arg(value); \ Result result = fmt::visit(TestVisitor(), arg); \ - EXPECT_EQ(Arg::type_code, result.arg.type); \ - EXPECT_EQ(value, ArgInfo::get(result.arg)); \ + EXPECT_EQ(format_arg::type_code, result.arg.type); \ + EXPECT_EQ(value, ArgInfo::get(result.arg)); \ } #define EXPECT_RESULT(type_code, value) \ @@ -654,13 +654,13 @@ TEST(ArgVisitorTest, VisitAll) { EXPECT_RESULT(POINTER, p); ::Test t; Result result = visit(TestVisitor(), make_arg(t)); - EXPECT_EQ(Arg::CUSTOM, result.arg.type); + EXPECT_EQ(format_arg::CUSTOM, result.arg.type); EXPECT_EQ(&t, result.arg.custom.value); } TEST(ArgVisitorTest, VisitInvalidArg) { - Arg arg = Arg(); - arg.type = static_cast(Arg::NONE); + format_arg arg = format_arg(); + arg.type = static_cast(format_arg::NONE); EXPECT_ASSERT(visit(TestVisitor(), arg), "invalid argument type"); }