Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / libc++ / trunk / test / containers / sequences / list / list.ops / remove.pass.cpp
index 76d878d..106c052 100644 (file)
 
 #include "min_allocator.h"
 
+struct S {
+       S(int i) : i_(new int(i)) {}
+       S(const S &rhs) : i_(new int(*rhs.i_)) {}
+       S& operator = (const S &rhs) { *i_ = *rhs.i_; return *this; }
+       ~S () { delete i_; i_ = NULL; }
+       bool operator == (const S &rhs) const { return *i_ == *rhs.i_; }
+       int get () const { return *i_; }
+       int *i_;
+       };
+
+
 int main()
 {
     {
@@ -25,6 +36,27 @@ int main()
     c.remove(3);
     assert(c == std::list<int>(a2, a2+3));
     }
+    {  // LWG issue #526
+    int a1[] = {1, 2, 1, 3, 5, 8, 11};
+    int a2[] = {   2,    3, 5, 8, 11};
+    std::list<int> c(a1, a1+7);
+    c.remove(c.front());
+    assert(c == std::list<int>(a2, a2+5));
+    }
+    {
+    int a1[] = {1, 2, 1, 3, 5, 8, 11, 1};
+    int a2[] = {   2,    3, 5, 8, 11   };
+    std::list<S> c;
+    for(int *ip = a1; ip < a1+8; ++ip)
+        c.push_back(S(*ip));
+    c.remove(c.front());
+    std::list<S>::const_iterator it = c.begin();
+    for(int *ip = a2; ip < a2+5; ++ip, ++it) {
+           assert ( it != c.end());
+        assert ( *ip == it->get());
+           }
+       assert ( it == c.end ());
+    }
 #if __cplusplus >= 201103L
     {
     int a1[] = {1, 2, 3, 4};