From c12e3d6e14df6d7613f6d6fae35dfb0fc7999418 Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Sun, 11 Oct 2015 22:51:54 +0200 Subject: [PATCH] Sphinx can't parse user-defined literals --- doc/api.rst | 2 ++ doc/build.py | 3 ++- doc/index.rst | 2 +- format.h | 10 ++++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/api.rst b/doc/api.rst index 7e1855a71d7bf..31f6eb69fa3af 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -26,6 +26,8 @@ arguments in the resulting string. .. doxygenfunction:: format(CStringRef, ArgList) +.. doxygenfunction:: operator""_format(const char *, std::size_t) + .. _print: .. doxygenfunction:: print(CStringRef, ArgList) diff --git a/doc/build.py b/doc/build.py index e2cea6a33c190..8bd71122225c2 100755 --- a/doc/build.py +++ b/doc/build.py @@ -53,7 +53,8 @@ def build_docs(): ALIASES += "endrst=\endverbatim" PREDEFINED = _WIN32=1 \ FMT_USE_VARIADIC_TEMPLATES=1 \ - FMT_USE_RVALUE_REFERENCES=1 + FMT_USE_RVALUE_REFERENCES=1 \ + FMT_USE_USER_DEFINED_LITERALS=1 EXCLUDE_SYMBOLS = fmt::internal::* StringValue write_str '''.format(os.path.dirname(doc_dir))) if p.returncode != 0: diff --git a/doc/index.rst b/doc/index.rst index a890776b2fcb7..35c56f04a7183 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -165,7 +165,7 @@ Although the library uses C++11 features when available, it also works with olde compilers and standard library implementations. The only thing to keep in mind for C++98 portability: -* Variadic templates: minimum GCC 4.4, Clang 2.9 or VS2013. This feature allow +* Variadic templates: minimum GCC 4.4, Clang 2.9 or VS2013. This feature allows the Format API to accept an unlimited number of arguments. With older compilers the maximum is 15. diff --git a/format.h b/format.h index e5e9153778ce9..12654502345eb 100644 --- a/format.h +++ b/format.h @@ -3044,6 +3044,16 @@ struct UdlArg { inline namespace literals { +/** + \rst + C++11 literal form of ``fmt::format``. + Requires ``using namespace fmt::literals``. + + **Example**:: + + std::string message = "The answer is {}"_format(42); + \endrst +*/ inline internal::UdlFormat operator"" _format(const char *s, std::size_t) { return {s}; } inline internal::UdlFormat