Fixed arg_formatter_base::write_pointer to not mutate the format specs.

This fixes cases where arg_formatters are reused, like with arg_join.
This commit is contained in:
Michael Winterberg
2018-04-30 11:09:40 -07:00
committed by Victor Zverovich
parent 6cd666100f
commit ca31ca13f1
2 changed files with 8 additions and 3 deletions
+4
View File
@@ -1287,6 +1287,7 @@ TEST(FormatTest, JoinArg) {
std::vector<float> v2;
v2.push_back(1.2f);
v2.push_back(3.4f);
void *v3[2] = { &v1[0], &v1[1] };
EXPECT_EQ("(1, 2, 3)", format("({})", join(v1, v1 + 3, ", ")));
EXPECT_EQ("(1)", format("({})", join(v1, v1 + 1, ", ")));
@@ -1298,6 +1299,9 @@ TEST(FormatTest, JoinArg) {
EXPECT_EQ(L"(1, 2, 3)", format(L"({})", join(v1, v1 + 3, L", ")));
EXPECT_EQ("1, 2, 3", format("{0:{1}}", join(v1, v1 + 3, ", "), 1));
EXPECT_EQ(format("{}, {}", v3[0], v3[1]),
format("{}", join(v3, v3 + 2, ", ")));
#if FMT_USE_TRAILING_RETURN && (!FMT_GCC_VERSION || FMT_GCC_VERSION >= 405)
EXPECT_EQ("(1, 2, 3)", format("({})", join(v1, ", ")));
EXPECT_EQ("(+01.20, +03.40)", format("({:+06.2f})", join(v2, ", ")));