Closed jrohel closed 5 years ago
Interesting. I'll run this through some test coverage...
@jrohel Thanks, it's great to have this! The posix syntax is something I've always thought would be nice to support but I've never had a reason to implement it myself. In fact, argument reordering is one of the main reasons I implemented the type-opaque FormatArg
wrapper stuff, and I'm pleased to see it allowed you to slot this in very neatly.
I probably won't have time to look at this closely for the next few days. At a quick glance it looks quite clean. One minor quibble - I'd appreciate it if you could reformat the braces to match the ambient style.
@c42f Ok. I changed the PR.
%0$
and asserts
are disabled (#define NDEBUG
).what is the status of this PR ? quite a handy feature but still open since last year !?
Thanks for the changes (all those months ago). Let's get this old thing over the line; I added a small refactoring which factors out some of the new code and adds a couple of tests.
The ability to rearrange formatting arguments is an important feature for localization because the word order may vary in different languages.
Without this we can't use tinyformat in projects where localization is required.
Example of reordering arguments in date (American to Germany format):
tfm::printf("%1$s, %3$d. %2$s, %4$d:%5$.2d\n", weekday, month, day, hour, min);