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 // UNSUPPORTED: c++03
9
10 // <vector>
11
12 // vector()
13 // noexcept(is_nothrow_default_constructible<allocator_type>::value);
14
15 // This *was* a conforming extension, but it was adopted in N4258.
16
17
18 #include <vector>
19 #include <cassert>
20
21 #include "test_macros.h"
22 #include "MoveOnly.h"
23 #include "test_allocator.h"
24
25 template <class T>
26 struct some_alloc
27 {
28 typedef T value_type;
29 some_alloc(const some_alloc&);
30 void allocate(std::size_t);
31 };
32
tests()33 TEST_CONSTEXPR_CXX20 bool tests() {
34 {
35 typedef std::vector<MoveOnly> C;
36 static_assert(std::is_nothrow_default_constructible<C>::value, "");
37 }
38 {
39 typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
40 static_assert(std::is_nothrow_default_constructible<C>::value, "");
41 }
42 {
43 typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
44 static_assert(!std::is_nothrow_default_constructible<C>::value, "");
45 }
46 {
47 typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
48 static_assert(!std::is_nothrow_default_constructible<C>::value, "");
49 }
50
51 return true;
52 }
53
main(int,char **)54 int main(int, char**)
55 {
56 tests();
57 #if TEST_STD_VER > 17
58 static_assert(tests());
59 #endif
60 return 0;
61 }
62