FMT C++ library: allow user to set format specifiers for custom type
The easiest solution is to inherit formatter<custom_type>
from formatter<double>
:
template <> struct fmt::formatter<custom_type> : formatter<double> {
auto format(custom_type c, format_context& ctx) {
return formatter<double>::format(c.value, ctx);
}
};
https://godbolt.org/z/6AHCOJ