]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / containers / unord / unord.set / unord.set.cnstr / move_assign_noexcept.pass.cpp
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 // <unordered_set>
11
12 // unordered_set& operator=(unordered_set&& c)
13 //     noexcept(
14 //          allocator_type::propagate_on_container_move_assignment::value &&
15 //          is_nothrow_move_assignable<allocator_type>::value &&
16 //          is_nothrow_move_assignable<key_compare>::value);
17
18 // This tests a conforming extension
19
20 // UNSUPPORTED: c++98, c++03
21
22 #include <unordered_set>
23 #include <cassert>
24
25 #include "test_macros.h"
26 #include "MoveOnly.h"
27 #include "test_allocator.h"
28
29 template <class T>
30 struct some_comp
31 {
32     typedef T value_type;
33     some_comp& operator=(const some_comp&);
34     bool operator()(const T&, const T&) const { return false; }
35 };
36
37 template <class T>
38 struct some_hash
39 {
40     typedef T value_type;
41     some_hash();
42     some_hash(const some_hash&);
43     some_hash& operator=(const some_hash&);
44 };
45
46 int main()
47 {
48     {
49         typedef std::unordered_set<MoveOnly> C;
50         static_assert(std::is_nothrow_move_assignable<C>::value, "");
51     }
52     {
53         typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
54                            std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
55         static_assert(!std::is_nothrow_move_assignable<C>::value, "");
56     }
57     {
58         typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
59                           std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
60         LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, "");
61     }
62     {
63         typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
64         static_assert(!std::is_nothrow_move_assignable<C>::value, "");
65     }
66     {
67         typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
68                                                          some_comp<MoveOnly>> C;
69         static_assert(!std::is_nothrow_move_assignable<C>::value, "");
70     }
71 }