Home | History | Annotate | Download | only in forwardlist.modifiers
      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 // <forward_list>
     11 
     12 // void clear();
     13 
     14 #include <forward_list>
     15 #include <cassert>
     16 
     17 #include "../../../NotConstructible.h"
     18 #include "min_allocator.h"
     19 
     20 int main()
     21 {
     22     {
     23         typedef NotConstructible T;
     24         typedef std::forward_list<T> C;
     25         C c;
     26         c.clear();
     27         assert(distance(c.begin(), c.end()) == 0);
     28     }
     29     {
     30         typedef int T;
     31         typedef std::forward_list<T> C;
     32         const T t[] = {0, 1, 2, 3, 4};
     33         C c(std::begin(t), std::end(t));
     34 
     35         c.clear();
     36         assert(distance(c.begin(), c.end()) == 0);
     37 
     38         c.clear();
     39         assert(distance(c.begin(), c.end()) == 0);
     40     }
     41 #if __cplusplus >= 201103L
     42     {
     43         typedef NotConstructible T;
     44         typedef std::forward_list<T, min_allocator<T>> C;
     45         C c;
     46         c.clear();
     47         assert(distance(c.begin(), c.end()) == 0);
     48     }
     49     {
     50         typedef int T;
     51         typedef std::forward_list<T, min_allocator<T>> C;
     52         const T t[] = {0, 1, 2, 3, 4};
     53         C c(std::begin(t), std::end(t));
     54 
     55         c.clear();
     56         assert(distance(c.begin(), c.end()) == 0);
     57 
     58         c.clear();
     59         assert(distance(c.begin(), c.end()) == 0);
     60     }
     61 #endif
     62 }
     63