[llvm-dev] RFC: General purpose type-safe formatting library

Pavel Labath via llvm-dev llvm-dev at lists.llvm.org
Wed Oct 12 02:33:55 PDT 2016


On 12 October 2016 at 05:26, Zachary Turner via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> os << format_string("Start: {0}, End: {1}, Elapsed: {2:ms}", start, end,
> start-end);

What would happen if I accidentally type "ps" instead of "ms" (I am
assuming we will not support picoseconds here)?

Will this abort at runtime?

I would prefer if *all* arguments to the format were checkable at compile time:
I.e. something like:
os << "blah blah" << format<std::milli>(end-start) << "blah blah";

I understand this may clash a bit with the desire for a compact
representation, but maybe with some clever design we could achieve
both?

pl


More information about the llvm-dev mailing list