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// UNSUPPORTED: c++03
10
11// <forward_list>
12
13// forward_list(initializer_list<value_type> il); // constexpr since C++26
14
15#include <forward_list>
16#include <cassert>
17
18#include "test_macros.h"
19#include "min_allocator.h"
20
21TEST_CONSTEXPR_CXX26 bool test() {
22 {
23 typedef int T;
24 typedef std::forward_list<T> C;
25 C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
26 int n = 0;
27 for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
28 assert(*i == n);
29 assert(n == 10);
30 }
31 {
32 typedef int T;
33 typedef std::forward_list<T, min_allocator<T>> C;
34 C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
35 int n = 0;
36 for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
37 assert(*i == n);
38 assert(n == 10);
39 }
40
41 return true;
42}
43
44int main(int, char**) {
45 assert(test());
46#if TEST_STD_VER >= 26
47 static_assert(test());
48#endif
49
50 return 0;
51}
52

source code of libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp