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

source code of libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp