| 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 | typedef T value_type; |
| 32 | some_comp(); |
| 33 | some_comp(const some_comp&); |
| 34 | bool operator()(const T&, const T&) const { return false; } |
| 35 | }; |
| 36 | |
| 37 | template <class T> |
| 38 | struct some_hash { |
| 39 | typedef T value_type; |
| 40 | some_hash(); |
| 41 | some_hash(const some_hash&); |
| 42 | std::size_t operator()(T const&) const; |
| 43 | }; |
| 44 | |
| 45 | int main(int, char**) { |
| 46 | #if defined(_LIBCPP_VERSION) |
| 47 | { |
| 48 | typedef std::unordered_multimap<MoveOnly, MoveOnly> C; |
| 49 | static_assert(std::is_nothrow_default_constructible<C>::value, "" ); |
| 50 | } |
| 51 | { |
| 52 | typedef std::unordered_multimap<MoveOnly, |
| 53 | MoveOnly, |
| 54 | std::hash<MoveOnly>, |
| 55 | std::equal_to<MoveOnly>, |
| 56 | test_allocator<std::pair<const MoveOnly, MoveOnly>>> |
| 57 | C; |
| 58 | static_assert(std::is_nothrow_default_constructible<C>::value, "" ); |
| 59 | } |
| 60 | #endif // _LIBCPP_VERSION |
| 61 | { |
| 62 | typedef std::unordered_multimap<MoveOnly, |
| 63 | MoveOnly, |
| 64 | std::hash<MoveOnly>, |
| 65 | std::equal_to<MoveOnly>, |
| 66 | other_allocator<std::pair<const MoveOnly, MoveOnly>>> |
| 67 | C; |
| 68 | static_assert(!std::is_nothrow_default_constructible<C>::value, "" ); |
| 69 | } |
| 70 | { |
| 71 | typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; |
| 72 | static_assert(!std::is_nothrow_default_constructible<C>::value, "" ); |
| 73 | } |
| 74 | { |
| 75 | typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C; |
| 76 | static_assert(!std::is_nothrow_default_constructible<C>::value, "" ); |
| 77 | } |
| 78 | |
| 79 | return 0; |
| 80 | } |
| 81 | |