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 pop_front();
     13 
     14 #include <forward_list>
     15 #include <cassert>
     16 
     17 #include "../../../MoveOnly.h"
     18 #include "../../../min_allocator.h"
     19 
     20 int main()
     21 {
     22     {
     23         typedef int T;
     24         typedef std::forward_list<T> C;
     25         typedef std::forward_list<T> C;
     26         C c;
     27         c.push_front(1);
     28         c.push_front(3);
     29         c.pop_front();
     30         assert(distance(c.begin(), c.end()) == 1);
     31         assert(c.front() == 1);
     32         c.pop_front();
     33         assert(distance(c.begin(), c.end()) == 0);
     34     }
     35 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     36     {
     37         typedef MoveOnly T;
     38         typedef std::forward_list<T> C;
     39         C c;
     40         c.push_front(1);
     41         c.push_front(3);
     42         c.pop_front();
     43         assert(distance(c.begin(), c.end()) == 1);
     44         assert(c.front() == 1);
     45         c.pop_front();
     46         assert(distance(c.begin(), c.end()) == 0);
     47     }
     48 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     49 #if __cplusplus >= 201103L
     50     {
     51         typedef int T;
     52         typedef std::forward_list<T, min_allocator<T>> C;
     53         typedef std::forward_list<T, min_allocator<T>> C;
     54         C c;
     55         c.push_front(1);
     56         c.push_front(3);
     57         c.pop_front();
     58         assert(distance(c.begin(), c.end()) == 1);
     59         assert(c.front() == 1);
     60         c.pop_front();
     61         assert(distance(c.begin(), c.end()) == 0);
     62     }
     63 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     64     {
     65         typedef MoveOnly T;
     66         typedef std::forward_list<T, min_allocator<T>> C;
     67         C c;
     68         c.push_front(1);
     69         c.push_front(3);
     70         c.pop_front();
     71         assert(distance(c.begin(), c.end()) == 1);
     72         assert(c.front() == 1);
     73         c.pop_front();
     74         assert(distance(c.begin(), c.end()) == 0);
     75     }
     76 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     77 #endif
     78 }
     79