std::formattable fails on custom std::formatter specialization
I wanted to ensure that my template argument can be formatted with std::format using the std::formattable concept. It works for all predefined types that come with c++23, but fails when I'm trying to pass my custom formatter struct Pair { int a, b; }; template <> struct std::formatter<Pair> : std::formatter<std::string> { auto format(const Pair& pair, std::format_context& ctx) const { return std::formatter<std::string>::format( std::format("{{{}, {}}}", pair.a, pair.b), ctx); } }; static_assert(std::formattable<Pair, char>); // fails
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.