[PATCH] D25587: Introduce llvm FormatVariadic

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 7 10:14:24 PST 2016


zturner added a comment.

In https://reviews.llvm.org/D25587#588213, @labath wrote:

> Will it be possible for the custom part of the format specifier to contain `:`? So we can specify custom formatting for time points with something like `formatv("{0:YYYY-MM-DD hh:mm:ss}", system_clock::now());`. (It does not seem that it will be a problem at a first glance, but I thought I'd check).


It was a problem in my original implementation, but it should not be a problem anymore.  The algorithm goes like this:

1. Find the first comma.  If it exists, everything up to the next colon (or end of string) is the alignment / justification field
2. From the endpoint of step 1, find the first colon.  If it exists, everything until the end of the string is the style specifier.

The only thing you simply cannot have within a style specifier is a curly brace, because that would terminate the replacement sequence.  (It might be possible to support by putting an escaped closing curly brace, but I didn't think it was necessary to complicated the parsing logic with this, especially since we aim to support static verification in the future, and for those purposes, the simpler the better).


https://reviews.llvm.org/D25587





More information about the llvm-commits mailing list