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 | // forward_list() // constexpr since C++26 |
12 | // forward_list::iterator() // constexpr since C++26 |
13 | // forward_list::const_iterator() // 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 | struct A { |
22 | std::forward_list<A> d; |
23 | std::forward_list<A>::iterator it; |
24 | std::forward_list<A>::const_iterator it2; |
25 | }; |
26 | |
27 | #if TEST_STD_VER >= 11 |
28 | struct B { |
29 | typedef std::forward_list<B, min_allocator<B>> FList; |
30 | FList d; |
31 | FList::iterator it; |
32 | FList::const_iterator it2; |
33 | }; |
34 | #endif |
35 | |
36 | TEST_CONSTEXPR_CXX26 bool test() { |
37 | { |
38 | A a; |
39 | assert(a.d.empty()); |
40 | a.it = a.d.begin(); |
41 | a.it2 = a.d.cbefore_begin(); |
42 | } |
43 | #if TEST_STD_VER >= 11 |
44 | { |
45 | B b; |
46 | assert(b.d.empty()); |
47 | b.it = b.d.begin(); |
48 | b.it2 = b.d.cbefore_begin(); |
49 | } |
50 | #endif |
51 | |
52 | return true; |
53 | } |
54 | |
55 | int main(int, char**) { |
56 | assert(test()); |
57 | #if TEST_STD_VER >= 26 |
58 | static_assert(test()); |
59 | #endif |
60 | |
61 | return 0; |
62 | } |
63 | |