tfc / pprintpp

Typesafe Python Style Printf Formatting for C++
MIT License
233 stars 12 forks source link

reorder printf paramters #1

Closed TorstenRobitzki closed 7 years ago

TorstenRobitzki commented 8 years ago

As you wrote in the FAQ, printfwill not reorder arguments as in the example of fmt: fmt::format("{0}{1}{0}", "abra", "cad"); but wouldn't it be possible to create a wrapper function that looks up a translation from the format string and rearranges the parameters before calling printf? This would allow use to create binaries that contains only the literals for a specific language and still supports a usage like gettext.

Example: printtext( "{1} beer to {0} guests.", 4, 2 );

could lookup the translation of "{1} beer to {0} guests." to the target language, check the arguments and then generate a function that rearranges the arguments when calling printf.

tfc commented 8 years ago

I updated the readme on that point. It is possible to to printf("%2$d %1$d", 1, 2);.

Assuming that functionality in printf, it seems overkill to implement that in the lib.