From f9561671cfaf9107942575b30c2422e9b675c8ba Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 21 Aug 2014 07:30:00 -0700 Subject: [PATCH] Write docs. --- doc/index.rst | 2 ++ format.h | 12 ++++++++++++ test/format-test.cc | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/doc/index.rst b/doc/index.rst index c80be732..77ef4a3e 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -31,6 +31,8 @@ namespace is usually omitted in examples. .. doxygenfunction:: fmt::print(std::FILE *, StringRef, const ArgList &) +.. doxygenfunction:: fmt::print(std::ostream &, StringRef, const ArgList &) + .. doxygendefine:: FMT_VARIADIC .. doxygenclass:: fmt::BasicWriter diff --git a/format.h b/format.h index 9386cd81..64859490 100644 --- a/format.h +++ b/format.h @@ -2004,6 +2004,18 @@ inline void format_decimal(char *&buffer, T value) { fmt::print(format, args); } FMT_VARIADIC(void, print_error, const char *, int, const char *) + + ``FMT_VARIADIC`` is used for compatibility with legacy C++ compilers that + don't implement variadic templates. You don't have to use this macro if + you don't need legacy compiler support and can use variadic templates + directly:: + + template + void print_error(const char *file, int line, const char *format, + const Args & ... args) { + fmt::print("{}: {}: ", file, line); + fmt::print(format, args...); + } \endrst */ #define FMT_VARIADIC(ReturnType, func, ...) \ diff --git a/test/format-test.cc b/test/format-test.cc index 1ac7daa3..2dd82602 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1545,3 +1545,12 @@ TEST(FormatTest, ArgConverter) { ArgConverter(arg, 'd').visit(arg); EXPECT_EQ(Arg::LONG_LONG, arg.type); } + +#if FMT_USE_VARIADIC_TEMPLATES +template +void print_error(const char *file, int line, const char *format, + const Args & ... args) { + fmt::print("{}: {}: ", file, line); + fmt::print(format, args...); +} +#endif