From b52e07822e85ffff11012ce1b83423369ecbc935 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Fri, 1 Aug 2014 00:04:31 +0800 Subject: [PATCH] Try to add erase-remove idiom in unit test but fail to compile on VC2013. --- test/unittest/valuetest.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/unittest/valuetest.cpp b/test/unittest/valuetest.cpp index 8655c852..2aa6379e 100644 --- a/test/unittest/valuetest.cpp +++ b/test/unittest/valuetest.cpp @@ -1,5 +1,6 @@ #include "unittest.h" #include "rapidjson/document.h" +#include using namespace rapidjson; @@ -674,6 +675,22 @@ TEST(Value, Array) { } } + // Working in gcc without C++11, but VS2013 cannot compile. To be diagnosed. +#if 0 + // http://en.wikipedia.org/wiki/Erase-remove_idiom + x.Clear(); + for (int i = 0; i < 10; i++) + if (i % 2 == 0) + x.PushBack(i, allocator); + else + x.PushBack(Value(kNullType).Move(), allocator); + + x.Erase(std::remove(x.Begin(), x.End(), Value(kNullType)), x.End()); + EXPECT_EQ(5u, x.Size()); + for (int i = 0; i < 5; i++) + EXPECT_EQ(i * 2, x[i]); +#endif + // SetArray() Value z; z.SetArray();