w
w copied to clipboard
Add advanced printf-style formatting options to w::format.
Currently w::format only does plain interpolation. It would be great if it could support syntax like this:
w::format("{0:.2}", 123); // => "0.00"
The format options should be per-interpolation, so the same argument can be interpolated multiple times with different format arguments:
w::format("{0:09.2} <=> {0:+x}", 10); // => "000000010.00 <=> +0xa"
For numbers (both integers and floats), all the options of POSIX printf should be supported. If a float-options is given to with an integer argument, or vice versa, the input value should be static_cast'ed to the appropriate type before interpolation.
Hexadecimal presentation formats should reinterpret_cast the input to a matching integer representation.