Skip to content

Commit

Permalink
Try to add erase-remove idiom in unit test but fail to compile on VC2…
Browse files Browse the repository at this point in the history
…013.
  • Loading branch information
miloyip committed Jul 31, 2014
1 parent c3ad232 commit b52e078
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/unittest/valuetest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "unittest.h"
#include "rapidjson/document.h"
#include <algorithm>

using namespace rapidjson;

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit b52e078

Please sign in to comment.