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

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