Возможности, потерянные в fmtlib по дороге к стандартизации.
template
struct fmt::formatter: formatter {
using formatter::parse;
auto format(const std::optional& opt, format_context& ctx) const {
if (opt.has_value()) {
format_to(ctx.out(), "Some(");
this->formatter::format(opt value(), ctx);
return format_to(ctx.out(), ")");
} else {
return format_to(ctx.out(), "None");
}
}
};
template
struct fmt::formatter: formatter {
using formatter::parse;
auto format(const std::optional& opt, format_context& ctx) const {
if (opt.has_value()) {
format_to(ctx.out(), "Some(");
this->formatter::format(opt value(), ctx);
return format_to(ctx.out(), ")");
} else {
return format_to(ctx.out(), "None");
}
}
};