Update core.h

Fix compilation when provided user-defined formatter for class instances like

template <>
struct fmt::formatter<Player*>
{
	static constexpr auto parse(format_parse_context &ctx)
	{
		return ctx.end();
	}

	template <typename FormatContext>
	auto format(const Player *player, FormatContext &ctx) const
	{
		return format_to(ctx.out(), "{}, device {}", player->id, player->device);
	}
};
This commit is contained in:
Nikolay 2021-07-02 17:19:35 +03:00 committed by GitHub
parent 889bbf27a2
commit c93208a04d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1300,7 +1300,9 @@ template <typename Context> struct arg_mapper {
// We use SFINAE instead of a const T* parameter to avoid conflicting with
// the C array overload.
template <typename T>
FMT_CONSTEXPR auto map(T) -> enable_if_t<std::is_pointer<T>::value, int> {
FMT_CONSTEXPR auto map(T) -> enable_if_t<std::is_pointer<T>::value &&
!has_formatter<T, Context>::value &&
!has_fallback_formatter<T, char_type>::value, int> {
// Formatting of arbitrary pointers is disallowed. If you want to output
// a pointer cast it to "void *" or "const void *". In particular, this
// forbids formatting of "[const] volatile char *" which is printed as bool