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
24template <class T>
25struct some_alloc {
26 typedef T value_type;
27 some_alloc(const some_alloc&);
28};
29
30int main(int, char**) {
31#if defined(_LIBCPP_VERSION)
32 {
33 typedef std::vector<bool> C;
34 static_assert(std::is_nothrow_move_constructible<C>::value, "");
35 }
36 {
37 typedef std::vector<bool, test_allocator<bool>> C;
38 static_assert(std::is_nothrow_move_constructible<C>::value, "");
39 }
40 {
41 typedef std::vector<bool, other_allocator<bool>> C;
42 static_assert(std::is_nothrow_move_constructible<C>::value, "");
43 }
44#endif // _LIBCPP_VERSION
45 {
46 // In C++17, move constructors for allocators are not allowed to throw
47#if TEST_STD_VER > 14
48# if defined(_LIBCPP_VERSION)
49 typedef std::vector<bool, some_alloc<bool>> C;
50 static_assert(std::is_nothrow_move_constructible<C>::value, "");
51# endif // _LIBCPP_VERSION
52#else
53 typedef std::vector<bool, some_alloc<bool>> C;
54 static_assert(!std::is_nothrow_move_constructible<C>::value, "");
55#endif
56 }
57
58 return 0;
59}
60

source code of libcxx/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp