• 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 
12 // vector& operator=(vector&& c)
13 //     noexcept(
14 //          allocator_type::propagate_on_container_move_assignment::value &&
15 //          is_nothrow_move_assignable<allocator_type>::value);
16 
17 // This tests a conforming extension
18 
19 // UNSUPPORTED: c++98, c++03
20 
21 #include <vector>
22 #include <cassert>
23 
24 #include "test_macros.h"
25 #include "test_allocator.h"
26 
27 template <class T>
28 struct some_alloc
29 {
30     typedef T value_type;
31     some_alloc(const some_alloc&);
32 };
33 
34 template <class T>
35 struct some_alloc2
36 {
37     typedef T value_type;
38 
some_alloc2some_alloc239     some_alloc2() {}
40     some_alloc2(const some_alloc2&);
deallocatesome_alloc241     void deallocate(void*, unsigned) {}
42 
43     typedef std::false_type propagate_on_container_move_assignment;
44     typedef std::true_type is_always_equal;
45 };
46 
47 template <class T>
48 struct some_alloc3
49 {
50     typedef T value_type;
51 
some_alloc3some_alloc352     some_alloc3() {}
53     some_alloc3(const some_alloc3&);
deallocatesome_alloc354     void deallocate(void*, unsigned) {}
55 
56     typedef std::false_type propagate_on_container_move_assignment;
57     typedef std::false_type is_always_equal;
58 };
59 
main()60 int main()
61 {
62 #if defined(_LIBCPP_VERSION)
63     {
64         typedef std::vector<bool> C;
65         static_assert(std::is_nothrow_move_assignable<C>::value, "");
66     }
67 #endif // _LIBCPP_VERSION
68     {
69         typedef std::vector<bool, test_allocator<bool>> C;
70         static_assert(!std::is_nothrow_move_assignable<C>::value, "");
71     }
72 #if defined(_LIBCPP_VERSION)
73     {
74         typedef std::vector<bool, other_allocator<bool>> C;
75         static_assert(std::is_nothrow_move_assignable<C>::value, "");
76     }
77 #endif // _LIBCPP_VERSION
78     {
79 #if TEST_STD_VER > 14
80 #if defined(_LIBCPP_VERSION)
81         typedef std::vector<bool, some_alloc<bool>> C;
82         static_assert( std::is_nothrow_move_assignable<C>::value, "");
83 #endif // _LIBCPP_VERSION
84 #else
85         typedef std::vector<bool, some_alloc<bool>> C;
86         static_assert(!std::is_nothrow_move_assignable<C>::value, "");
87 #endif
88     }
89 #if TEST_STD_VER > 14
90 #if defined(_LIBCPP_VERSION)
91     {  // POCMA false, is_always_equal true
92         typedef std::vector<bool, some_alloc2<bool>> C;
93         static_assert( std::is_nothrow_move_assignable<C>::value, "");
94     }
95 #endif // _LIBCPP_VERSION
96     {  // POCMA false, is_always_equal false
97         typedef std::vector<bool, some_alloc3<bool>> C;
98         static_assert(!std::is_nothrow_move_assignable<C>::value, "");
99     }
100 #endif
101 }
102