• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // <vector>
11 // vector<bool>
12 
13 // vector(const Alloc& = Alloc());
14 
15 #include <vector>
16 #include <cassert>
17 
18 #include "test_macros.h"
19 #include "test_allocator.h"
20 #include "min_allocator.h"
21 
22 template <class C>
23 void
test0()24 test0()
25 {
26 #if TEST_STD_VER > 14
27 	static_assert((noexcept(C{})), "" );
28 #elif TEST_STD_VER >= 11
29 	static_assert((noexcept(C()) == noexcept(typename C::allocator_type())), "" );
30 #endif
31     C c;
32     assert(c.__invariants());
33     assert(c.empty());
34     assert(c.get_allocator() == typename C::allocator_type());
35 #if TEST_STD_VER >= 11
36     C c1 = {};
37     assert(c1.__invariants());
38     assert(c1.empty());
39     assert(c1.get_allocator() == typename C::allocator_type());
40 #endif
41 }
42 
43 template <class C>
44 void
test1(const typename C::allocator_type & a)45 test1(const typename C::allocator_type& a)
46 {
47 #if TEST_STD_VER > 14
48 	static_assert((noexcept(C{typename C::allocator_type{}})), "" );
49 #elif TEST_STD_VER >= 11
50 	static_assert((noexcept(C(typename C::allocator_type())) == std::is_nothrow_copy_constructible<typename C::allocator_type>::value), "" );
51 #endif
52     C c(a);
53     assert(c.__invariants());
54     assert(c.empty());
55     assert(c.get_allocator() == a);
56 }
57 
main()58 int main()
59 {
60     {
61     test0<std::vector<bool> >();
62     test1<std::vector<bool, test_allocator<bool> > >(test_allocator<bool>(3));
63     }
64 #if TEST_STD_VER >= 11
65     {
66     test0<std::vector<bool, min_allocator<bool>> >();
67     test1<std::vector<bool, min_allocator<bool> > >(min_allocator<bool>());
68     }
69 #endif
70 }
71