From 9d2221b954477836088279e0f0f7eb4d9f61af13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Wed, 19 Sep 2018 14:51:01 +0200 Subject: [PATCH] Improve error message when formatting unknown types --- include/fmt/core.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index a054f976..e204ae00 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -340,9 +340,22 @@ class basic_format_arg; template class basic_format_args; +template +struct no_formatter_error : std::false_type {}; + // A formatter for objects of type T. template -struct formatter; +struct formatter { + static_assert(no_formatter_error::value, + "don't know how to format the type, include fmt/ostream.h if it provides " + "an operator<< that should be used"); + + // The following functions are not defined intentionally. + template + typename ParseContext::iterator parse(ParseContext &); + template + auto format(const T &val, FormatContext &ctx) -> decltype(ctx.out()); +}; template struct convert_to_int {