For some reason (ehm CUDA) I use printf()
in my C++ code. I would like to be able to template around some of these uses - but for that to happen I need to obtain the printf type specifier for various types. Suppose I only need this to work for types which actually have relevant specifiers; and that I don't really care about scientific vs. decimal notation and other such details.
Is there an idiomatic way of doing this other than having a lookup table?
Note: I would like this to all happen at compile time, not run time. Despite printf()
itself only parsing it at run-time.