Increase the maximum number of formatting arguments on compilers without variadic templates to 15.

This commit is contained in:
Victor Zverovich 2014-09-11 21:18:36 -07:00
parent 445663fade
commit d59fbdcd4a
2 changed files with 26 additions and 10 deletions

View File

@ -1128,6 +1128,11 @@ inline StrFormatSpec<wchar_t> pad(
# define FMT_GEN8(f) FMT_GEN7(f), f(7)
# define FMT_GEN9(f) FMT_GEN8(f), f(8)
# define FMT_GEN10(f) FMT_GEN9(f), f(9)
# define FMT_GEN11(f) FMT_GEN10(f), f(10)
# define FMT_GEN12(f) FMT_GEN11(f), f(11)
# define FMT_GEN13(f) FMT_GEN12(f), f(12)
# define FMT_GEN14(f) FMT_GEN13(f), f(13)
# define FMT_GEN15(f) FMT_GEN14(f), f(14)
# define FMT_MAKE_TEMPLATE_ARG(n) typename T##n
# define FMT_MAKE_ARG(n) const T##n &v##n
@ -1999,7 +2004,12 @@ inline void format_decimal(char *&buffer, T value) {
FMT_WRAP(Char, ReturnType, func, call, 7, __VA_ARGS__) \
FMT_WRAP(Char, ReturnType, func, call, 8, __VA_ARGS__) \
FMT_WRAP(Char, ReturnType, func, call, 9, __VA_ARGS__) \
FMT_WRAP(Char, ReturnType, func, call, 10, __VA_ARGS__)
FMT_WRAP(Char, ReturnType, func, call, 10, __VA_ARGS__) \
FMT_WRAP(Char, ReturnType, func, call, 11, __VA_ARGS__) \
FMT_WRAP(Char, ReturnType, func, call, 12, __VA_ARGS__) \
FMT_WRAP(Char, ReturnType, func, call, 13, __VA_ARGS__) \
FMT_WRAP(Char, ReturnType, func, call, 14, __VA_ARGS__) \
FMT_WRAP(Char, ReturnType, func, call, 15, __VA_ARGS__)
#endif // FMT_USE_VARIADIC_TEMPLATES
/**

View File

@ -1536,3 +1536,9 @@ void print_error(const char *file, int line, const char *format,
fmt::print(format, args...);
}
#endif
TEST(FormatTest, MaxArgs) {
EXPECT_EQ("0123456789abcde",
fmt::format("{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e'));
}