Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message when formatting unknown types #872

Merged
merged 1 commit into from
Sep 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,22 @@ class basic_format_arg;
template <typename Context>
class basic_format_args;

template <typename T>
struct no_formatter_error : std::false_type {};

// A formatter for objects of type T.
template <typename T, typename Char = char, typename Enable = void>
struct formatter;
struct formatter {
static_assert(no_formatter_error<T>::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>
typename ParseContext::iterator parse(ParseContext &);
template <typename FormatContext>
auto format(const T &val, FormatContext &ctx) -> decltype(ctx.out());
};

template <typename T, typename Char, typename Enable = void>
struct convert_to_int {
Expand Down