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_set>
10
11// unordered_multiset()
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_set>
22#include <cassert>
23
24#include "test_macros.h"
25#include "MoveOnly.h"
26#include "test_allocator.h"
27#include "../../../test_hash.h"
28
29template <class T>
30struct 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
37template <class T>
38struct 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
45int main(int, char**) {
46#if defined(_LIBCPP_VERSION)
47 {
48 typedef std::unordered_multiset<MoveOnly> C;
49 static_assert(std::is_nothrow_default_constructible<C>::value, "");
50 }
51 {
52 typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
53 static_assert(std::is_nothrow_default_constructible<C>::value, "");
54 }
55#endif // _LIBCPP_VERSION
56 {
57 typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>>
58 C;
59 static_assert(!std::is_nothrow_default_constructible<C>::value, "");
60 }
61 {
62 typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
63 static_assert(!std::is_nothrow_default_constructible<C>::value, "");
64 }
65 {
66 typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C;
67 static_assert(!std::is_nothrow_default_constructible<C>::value, "");
68 }
69
70 return 0;
71}
72

source code of libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp