-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
I have said before, but it is worth saying again -- thanks for working on fmt; it is great and a pleasure to use!
I have a question about formatting user defined types. The point example in the documentation leaves me with a question that I do not know how to answer. To extend the point example to be even more practical:
How can I make a custom point formatter that reuses the parse context and specifiers (these may not be the right terms) for the underlying double type?
For example, I would like to format a point where formatter parse and format use any of the underlying double specifiers. And example usage might be
point p = {1.001, 2.0015};
std::string s = fmt::format("{:.3f}", p);
// s == "(1.001, 2.002)"
where the parse function sees the .3f specifier and uses that in the format function.
Additional extensions might be: how to specify independent specifiers for the x and y components? How to have the specifier for y be optional and if not specified is the same as the x specifier.
If someone can point me in the right direction, I will attempt to provide an update to the example documentation.
Thanks!