Docs: add comment about empty format context range

This commit is contained in:
Alex 2022-06-02 21:38:15 +07:00 committed by Victor Zverovich
parent ba50c19e82
commit 8644654190

View File

@ -210,6 +210,10 @@ template and implement ``parse`` and ``format`` methods::
// the formatter should parse the 'f' specifier and return an iterator
// pointing to '}'.
// Please also note that this character range may be empty, in case of
// the "{}" format string, so therefore you should check ctx.begin()
// for equality with ctx.end().
// Parse the presentation format and store it in the formatter:
auto it = ctx.begin(), end = ctx.end();
if (it != end && (*it == 'f' || *it == 'e')) presentation = *it++;