1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <forward_list>
11
12 // forward_list(const forward_list& x, const allocator_type& a);
13
14 #include <forward_list>
15 #include <cassert>
16 #include <iterator>
17
18 #include "test_allocator.h"
19 #include "min_allocator.h"
20
main()21 int main()
22 {
23 {
24 typedef int T;
25 typedef test_allocator<int> A;
26 typedef std::forward_list<T, A> C;
27 const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
28 C c0(std::begin(t), std::end(t), A(10));
29 C c(c0, A(9));
30 unsigned n = 0;
31 for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
32 assert(*i == n);
33 assert(n == std::end(t) - std::begin(t));
34 assert(c == c0);
35 assert(c.get_allocator() == A(9));
36 }
37 {
38 typedef int T;
39 typedef other_allocator<int> A;
40 typedef std::forward_list<T, A> C;
41 const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
42 C c0(std::begin(t), std::end(t), A(10));
43 C c(c0, A(9));
44 unsigned n = 0;
45 for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
46 assert(*i == n);
47 assert(n == std::end(t) - std::begin(t));
48 assert(c == c0);
49 assert(c.get_allocator() == A(9));
50 }
51 #if __cplusplus >= 201103L
52 {
53 typedef int T;
54 typedef min_allocator<int> A;
55 typedef std::forward_list<T, A> C;
56 const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
57 C c0(std::begin(t), std::end(t), A());
58 C c(c0, A());
59 unsigned n = 0;
60 for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
61 assert(*i == n);
62 assert(n == std::end(t) - std::begin(t));
63 assert(c == c0);
64 assert(c.get_allocator() == A());
65 }
66 #endif
67 }
68