]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp
Vendor import of libc++ release_39 branch r276489:
[FreeBSD/FreeBSD.git] / test / std / containers / unord / unord.map / unord.map.cnstr / dtor_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_map>
11
12 // ~unordered_map() // implied noexcept;
13
14 // UNSUPPORTED: c++98, c++03
15
16 #include <unordered_map>
17 #include <cassert>
18
19 #include "MoveOnly.h"
20 #include "test_allocator.h"
21
22 template <class T>
23 struct some_comp
24 {
25     typedef T value_type;
26     ~some_comp() noexcept(false);
27     bool operator()(const T&, const T&) const { return false; }
28 };
29
30 template <class T>
31 struct some_hash
32 {
33     typedef T value_type;
34     some_hash();
35     some_hash(const some_hash&);
36     ~some_hash() noexcept(false);
37 };
38
39 int main()
40 {
41     {
42         typedef std::unordered_map<MoveOnly, MoveOnly> C;
43         static_assert(std::is_nothrow_destructible<C>::value, "");
44     }
45     {
46         typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
47                            std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
48         static_assert(std::is_nothrow_destructible<C>::value, "");
49     }
50     {
51         typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
52                           std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
53         static_assert(std::is_nothrow_destructible<C>::value, "");
54     }
55     {
56         typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
57         static_assert(!std::is_nothrow_destructible<C>::value, "");
58     }
59     {
60         typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
61                                                          some_comp<MoveOnly>> C;
62         static_assert(!std::is_nothrow_destructible<C>::value, "");
63     }
64 }