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

Pavel Labath via llvm-dev
Wed, 12 Oct 2016 09:33:55 -0000

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