I am currently trying to pass an arbitrary number of parameters of MyType
to fprintf
like this:
void myPrint(const char* fmt, std::initializer_list<MyType> args)
{
fprintf(stdout, fmt, args);
}
where MyType
is basically a variant and can be constructed from most common types (int, string, uint*, bool, ...). Now when calling myPrint(...)
like this
myPrint("I am a hex int: %x", { 5 } );
this will always print the address of the initializer_list
. When looking at the references, e.g. cplusplus.com, it says
[...] If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers. [...]
[...] Each function argument (if any) is converted and output according to the corresponding format specification in format. [...]
So, my question is: How does fprintf
format or convert its arguments? Does it use operators? Does it use casts?