Home | History | Annotate | Download | only in list.ops
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <list>
     11 
     12 // template <class Pred> void remove_if(Pred pred);
     13 
     14 #include <list>
     15 #include <cassert>
     16 #include <functional>
     17 
     18 #include "min_allocator.h"
     19 
     20 bool g(int i)
     21 {
     22     return i < 3;
     23 }
     24 
     25 int main()
     26 {
     27     {
     28     int a1[] = {1, 2, 3, 4};
     29     int a2[] = {3, 4};
     30     std::list<int> c(a1, a1+4);
     31     c.remove_if(g);
     32     assert(c == std::list<int>(a2, a2+2));
     33     }
     34 #if __cplusplus >= 201103L
     35     {
     36     int a1[] = {1, 2, 3, 4};
     37     int a2[] = {3, 4};
     38     std::list<int, min_allocator<int>> c(a1, a1+4);
     39     c.remove_if(g);
     40     assert((c == std::list<int, min_allocator<int>>(a2, a2+2)));
     41     }
     42 #endif
     43 }
     44