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 // <unordered_map>
10 
11 // unordered_multimap()
12 //    noexcept(
13 //        is_nothrow_default_constructible<allocator_type>::value &&
14 //        is_nothrow_default_constructible<key_compare>::value &&
15 //        is_nothrow_copy_constructible<key_compare>::value);
16 
17 // This tests a conforming extension
18 
19 // UNSUPPORTED: c++03
20 
21 #include <unordered_map>
22 #include <cassert>
23 
24 #include "test_macros.h"
25 #include "MoveOnly.h"
26 #include "test_allocator.h"
27 #include "../../../test_hash.h"
28 
29 template <class T>
30 struct some_comp
31 {
32     typedef T value_type;
33     some_comp();
34     some_comp(const some_comp&);
operator ()some_comp35     bool operator()(const T&, const T&) const { return false; }
36 };
37 
38 template <class T>
39 struct some_hash
40 {
41     typedef T value_type;
42     some_hash();
43     some_hash(const some_hash&);
44     std::size_t operator()(T const&) const;
45 };
46 
main(int,char **)47 int main(int, char**)
48 {
49 #if defined(_LIBCPP_VERSION)
50     {
51         typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
52         static_assert(std::is_nothrow_default_constructible<C>::value, "");
53     }
54     {
55         typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
56                            std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
57         static_assert(std::is_nothrow_default_constructible<C>::value, "");
58     }
59 #endif // _LIBCPP_VERSION
60     {
61         typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
62                           std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
63         static_assert(!std::is_nothrow_default_constructible<C>::value, "");
64     }
65     {
66         typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
67         static_assert(!std::is_nothrow_default_constructible<C>::value, "");
68     }
69     {
70         typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
71                                                          some_comp<MoveOnly>> C;
72         static_assert(!std::is_nothrow_default_constructible<C>::value, "");
73     }
74 
75   return 0;
76 }
77