#include <map>
#include <fmt/format.h>
#include <fmt/ranges.h>
#include <fmt/std.h>
#include <fmt/ostream.h>
struct x {};
template <typename K>
struct fmt::formatter<std::pair<K, x>> : fmt::formatter<std::string_view> {
auto format(const std::pair<K, x>& p, auto& ctx) const {
return fmt::format_to(ctx.out(), "x/x");
}
};
int main() {
std::map<x, x> v{{}, {}};
fmt::print("{}\n", v);
return 0;
}
This doesn't build, since map's formatter calls the pair formatter's set_brackets() and set_separator(), which don't exist.
set_brackets() and set_separator() are undocumented, so it's not reasonable to expect them to exist.
I think map's formatter should check to see if it's using the standard pair formatter before calling undocumented methods.
This doesn't build, since map's formatter calls the pair formatter's set_brackets() and set_separator(), which don't exist.
set_brackets() and set_separator() are undocumented, so it's not reasonable to expect them to exist.
I think map's formatter should check to see if it's using the standard pair formatter before calling undocumented methods.