1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template <class InputIter> vector(InputIter first, InputIter last,
13 // const allocator_type& a);
18 #include "test_iterators.h"
19 #include "../../../stack_allocator.h"
20 #include "min_allocator.h"
21 #include "asan_testing.h"
23 template <class C, class Iterator, class A>
25 test(Iterator first, Iterator last, const A& a)
28 assert(c.__invariants());
29 assert(c.size() == std::distance(first, last));
30 assert(is_contiguous_container_asan_correct(c));
31 for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
35 #if __cplusplus >= 201103L
38 struct implicit_conv_allocator : min_allocator<T>
40 implicit_conv_allocator(void* p) {}
41 implicit_conv_allocator(const implicit_conv_allocator&) = default;
49 int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
50 int* an = a + sizeof(a)/sizeof(a[0]);
51 std::allocator<int> alloc;
52 test<std::vector<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
53 test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);
54 test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
55 test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
56 test<std::vector<int> >(a, an, alloc);
58 #if __cplusplus >= 201103L
60 int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
61 int* an = a + sizeof(a)/sizeof(a[0]);
62 min_allocator<int> alloc;
63 test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
64 test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);
65 test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
66 test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
67 test<std::vector<int, min_allocator<int>> >(a, an, alloc);
68 test<std::vector<int, implicit_conv_allocator<int>> >(a, an, nullptr);