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