Allow absolute index to be used when all values has been used.

This commit is contained in:
Oldřich Jedlička 2014-05-29 10:47:34 +02:00
parent 5cd3e842e8
commit 2cdfa7ae57
2 changed files with 4 additions and 1 deletions

View File

@ -350,7 +350,7 @@ void format(std::string& result, const std::string& fmt, const std::vector<Any>&
{
case '%':
++itFmt;
if (itFmt != endFmt && itVal != endVal)
if (itFmt != endFmt && (itVal != endVal || *itFmt == '['))
{
if (*itFmt == '[')
{

View File

@ -349,6 +349,9 @@ void FormatTest::testIndex()
s = format("%%%[1]d%%%[2]d%%%d", 1, 2, 3);
assert(s == "%2%3%1");
s = format("%%%d%%%d%%%[0]d", 1, 2);
assert(s == "%1%2%1");
}