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, const allocator_type& a); |
14 | |
15 | #include <forward_list> |
16 | #include <cassert> |
17 | |
18 | #include "test_macros.h" |
19 | #include "test_allocator.h" |
20 | #include "min_allocator.h" |
21 | |
22 | int main(int, char**) |
23 | { |
24 | { |
25 | typedef int T; |
26 | typedef test_allocator<T> A; |
27 | typedef std::forward_list<T, A> C; |
28 | C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A(14)); |
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 == 10); |
33 | assert(c.get_allocator() == A(14)); |
34 | } |
35 | { |
36 | typedef int T; |
37 | typedef min_allocator<T> A; |
38 | typedef std::forward_list<T, A> C; |
39 | C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A()); |
40 | int n = 0; |
41 | for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) |
42 | assert(*i == n); |
43 | assert(n == 10); |
44 | assert(c.get_allocator() == A()); |
45 | } |
46 | |
47 | return 0; |
48 | } |
49 | |