These are chat archives for fmtlib/fmt

24th
Oct 2017
Victor Zverovich
@vitaut
Oct 24 2017 01:50
PrintfArgFormatter should be used with PrintfFormatter: https://github.com/fmtlib/fmt/blob/master/fmt/printf.h#L312
Take a look at how fmt::printf is implemented: https://github.com/fmtlib/fmt/blob/master/fmt/printf.h#L523
You can create customize PrintfArgFormatter and pass it as a second template argument there.
Michael Schiller
@M-Schiller
Oct 24 2017 08:32
Ah, thank you. I have my minimal example working now. I now observed that visit_custom is called whenever I pass a MyVariantto my print function with the CustomValue.value being a pointer to the MyVariant instance. I could not find where this happens in the code and was thinking about if it was possible to having unpacked the MyVariant beforehand (and extracting the string, int, char, ...) as to not having to cast the void*or if there is an easy way of formatting MyVariant using the printf - format string like ... myPrintf("%03d", MyVariant(4)); --> "004"
Michael Schiller
@M-Schiller
Oct 24 2017 09:06
I also think that the spec is lost when visiting a custom type:
myPrintf("%03 %03", 4, MyVariant(4));has a WidthSpec of (width=3, fill = '0') for '4' and (width=3, fill = ' ') for the MyVariant(4)