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_set() // implied noexcept;
12
13// UNSUPPORTED: c++03
14
15#include <unordered_set>
16#include <cassert>
17
18#include "test_macros.h"
19#include "MoveOnly.h"
20#include "test_allocator.h"
21
22template <class T>
23struct some_comp {
24 typedef T value_type;
25 ~some_comp() noexcept(false);
26 bool operator()(const T&, const T&) const { return false; }
27};
28
29template <class T>
30struct some_hash {
31 typedef T value_type;
32 some_hash();
33 some_hash(const some_hash&);
34 ~some_hash() noexcept(false);
35 std::size_t operator()(T const&) const;
36};
37
38int main(int, char**) {
39 {
40 typedef std::unordered_set<MoveOnly> C;
41 static_assert(std::is_nothrow_destructible<C>::value, "");
42 }
43 {
44 typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
45 static_assert(std::is_nothrow_destructible<C>::value, "");
46 }
47 {
48 typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
49 static_assert(std::is_nothrow_destructible<C>::value, "");
50 }
51#if defined(_LIBCPP_VERSION)
52 {
53 typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
54 static_assert(!std::is_nothrow_destructible<C>::value, "");
55 }
56 {
57 typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C;
58 static_assert(!std::is_nothrow_destructible<C>::value, "");
59 }
60#endif // _LIBCPP_VERSION
61
62 return 0;
63}
64

source code of libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp