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// template <class InputIterator>
12// forward_list(InputIterator first, InputIterator last); // constexpr since C++26
13
14#include <forward_list>
15#include <cassert>
16#include <iterator>
17
18#include "test_macros.h"
19#include "test_iterators.h"
20#include "min_allocator.h"
21
22TEST_CONSTEXPR_CXX26 bool test() {
23 {
24 typedef int T;
25 typedef std::forward_list<T> C;
26 typedef cpp17_input_iterator<const T*> I;
27 const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
28 C c(I(std::begin(arr: t)), I(std::end(arr: t)));
29 int n = 0;
30 for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
31 assert(*i == n);
32 assert(n == std::end(t) - std::begin(t));
33 }
34#if TEST_STD_VER >= 11
35 {
36 typedef int T;
37 typedef std::forward_list<T, min_allocator<T>> C;
38 typedef cpp17_input_iterator<const T*> I;
39 const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
40 C c(I(std::begin(t)), I(std::end(t)));
41 int n = 0;
42 for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
43 assert(*i == n);
44 assert(n == std::end(t) - std::begin(t));
45 }
46#endif
47
48 return true;
49}
50
51int main(int, char**) {
52 assert(test());
53#if TEST_STD_VER >= 26
54 static_assert(test());
55#endif
56
57 return 0;
58}
59

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