1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // <forward_list> |
10 | |
11 | // void pop_front(); |
12 | |
13 | #include <forward_list> |
14 | #include <cassert> |
15 | |
16 | #include "test_macros.h" |
17 | #include "MoveOnly.h" |
18 | #include "min_allocator.h" |
19 | |
20 | int main(int, char**) |
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(val: 1); |
28 | c.push_front(val: 3); |
29 | c.pop_front(); |
30 | assert(std::distance(c.begin(), c.end()) == 1); |
31 | assert(c.front() == 1); |
32 | c.pop_front(); |
33 | assert(std::distance(c.begin(), c.end()) == 0); |
34 | } |
35 | #if TEST_STD_VER >= 11 |
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(std::distance(c.begin(), c.end()) == 1); |
44 | assert(c.front() == 1); |
45 | c.pop_front(); |
46 | assert(std::distance(c.begin(), c.end()) == 0); |
47 | } |
48 | { |
49 | typedef int T; |
50 | typedef std::forward_list<T, min_allocator<T>> C; |
51 | typedef std::forward_list<T, min_allocator<T>> C; |
52 | C c; |
53 | c.push_front(1); |
54 | c.push_front(3); |
55 | c.pop_front(); |
56 | assert(std::distance(c.begin(), c.end()) == 1); |
57 | assert(c.front() == 1); |
58 | c.pop_front(); |
59 | assert(std::distance(c.begin(), c.end()) == 0); |
60 | } |
61 | { |
62 | typedef MoveOnly T; |
63 | typedef std::forward_list<T, min_allocator<T>> C; |
64 | C c; |
65 | c.push_front(1); |
66 | c.push_front(3); |
67 | c.pop_front(); |
68 | assert(std::distance(c.begin(), c.end()) == 1); |
69 | assert(c.front() == 1); |
70 | c.pop_front(); |
71 | assert(std::distance(c.begin(), c.end()) == 0); |
72 | } |
73 | #endif |
74 | |
75 | return 0; |
76 | } |
77 | |