formatter simply inheriting from built-in formatter is not recognised · Issue #4036 · fmtlib/fmt · GitHub
Skip to content

formatter simply inheriting from built-in formatter is not recognised #4036

Description

@gnbond

libfmt 10.2 / gcc 13

I have a string-like class implicitly-convertible to std::string_view. Based on older documentation I'd expect that to Just Work in fmt::format()but I see from other issues that matching on implicit conversion has been disabled. Annoying, but fair enough.

When I create a fmt::formatter specialisation for my class that simply inherits fmt::formatter<string_view>, this does not work, fmt::format still considers S to be an un-formattable type.

template<>
class fmt::formatter<S> 
    : public fmt::formatter<std::string_view> {};

https://godbolt.org/z/aMqqWaso9

The equivalent code using std::formatter works ok: https://godbolt.org/z/T7zzKzzf3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions