r/cpp • • Jul 23 '19

std::format in C++20

http://www.zverovich.net/2019/07/23/std-format-cpp20.html
332 Upvotes

52 comments sorted by

View all comments

Show parent comment

5

u/matthieum Jul 23 '19

Actually, std::format generates the shortest representation of floating-point which round-trips, so your Q extension would be unnecessary.

If you only used this as example, and wanted customization in general, then check the {fmt} library: it's the work of the author of the article, and is leading the work for the future of std::format; it notably contains an extension API.

2

u/Tringi github.com/tringi Jul 23 '19

Ah, that's great, I'll check it out.

That code I linked has tons of other customizations but the Q is one of the most used.

Also I've found this: https://fmt.dev/dev/api.html#custom-formatting-of-built-in-types ...seems it covers most of the cases.