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 | // class forward_list |
12 | |
13 | // bool empty() const noexcept; // constexpr since C++26 |
14 | |
15 | #include <forward_list> |
16 | #include <cassert> |
17 | |
18 | #include "test_macros.h" |
19 | #include "min_allocator.h" |
20 | |
21 | TEST_CONSTEXPR_CXX26 bool test() { |
22 | { |
23 | typedef std::forward_list<int> C; |
24 | C c; |
25 | ASSERT_NOEXCEPT(c.empty()); |
26 | assert(c.empty()); |
27 | c.push_front(val: C::value_type(1)); |
28 | assert(!c.empty()); |
29 | c.clear(); |
30 | assert(c.empty()); |
31 | } |
32 | #if TEST_STD_VER >= 11 |
33 | { |
34 | typedef std::forward_list<int, min_allocator<int>> C; |
35 | C c; |
36 | ASSERT_NOEXCEPT(c.empty()); |
37 | assert(c.empty()); |
38 | c.push_front(C::value_type(1)); |
39 | assert(!c.empty()); |
40 | c.clear(); |
41 | assert(c.empty()); |
42 | } |
43 | #endif |
44 | |
45 | return true; |
46 | } |
47 | |
48 | int main(int, char**) { |
49 | assert(test()); |
50 | #if TEST_STD_VER >= 26 |
51 | static_assert(test()); |
52 | #endif |
53 | |
54 | return 0; |
55 | } |
56 | |