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 //===----------------------------------------------------------------------===//
13 // vector(const Alloc&);
18 #include "test_macros.h"
19 #include "test_allocator.h"
20 #include "../../../NotConstructible.h"
21 #include "../../../stack_allocator.h"
22 #include "min_allocator.h"
23 #include "asan_testing.h"
30 static_assert((noexcept(C{})), "" );
31 #elif TEST_STD_VER >= 11
32 static_assert((noexcept(C()) == noexcept(typename C::allocator_type())), "" );
35 LIBCPP_ASSERT(c.__invariants());
37 assert(c.get_allocator() == typename C::allocator_type());
38 LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
39 #if TEST_STD_VER >= 11
41 LIBCPP_ASSERT(c1.__invariants());
43 assert(c1.get_allocator() == typename C::allocator_type());
44 LIBCPP_ASSERT(is_contiguous_container_asan_correct(c1));
50 test1(const typename C::allocator_type& a)
53 static_assert((noexcept(C{typename C::allocator_type{}})), "" );
54 #elif TEST_STD_VER >= 11
55 static_assert((noexcept(C(typename C::allocator_type())) == std::is_nothrow_copy_constructible<typename C::allocator_type>::value), "" );
58 LIBCPP_ASSERT(c.__invariants());
60 assert(c.get_allocator() == a);
61 LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
67 test0<std::vector<int> >();
68 test0<std::vector<NotConstructible> >();
69 test1<std::vector<int, test_allocator<int> > >(test_allocator<int>(3));
70 test1<std::vector<NotConstructible, test_allocator<NotConstructible> > >
71 (test_allocator<NotConstructible>(5));
74 std::vector<int, stack_allocator<int, 10> > v;
77 #if TEST_STD_VER >= 11
79 test0<std::vector<int, min_allocator<int>> >();
80 test0<std::vector<NotConstructible, min_allocator<NotConstructible>> >();
81 test1<std::vector<int, min_allocator<int> > >(min_allocator<int>{});
82 test1<std::vector<NotConstructible, min_allocator<NotConstructible> > >
83 (min_allocator<NotConstructible>{});
86 std::vector<int, min_allocator<int> > v;
91 test0<std::vector<int, explicit_allocator<int>> >();
92 test0<std::vector<NotConstructible, explicit_allocator<NotConstructible>> >();
93 test1<std::vector<int, explicit_allocator<int> > >(explicit_allocator<int>{});
94 test1<std::vector<NotConstructible, explicit_allocator<NotConstructible> > >
95 (explicit_allocator<NotConstructible>{});
98 std::vector<int, explicit_allocator<int> > v;