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// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10
11// <flat_set>
12
13// ~flat_set();
14
15#include <cassert>
16#include <deque>
17#include <flat_set>
18#include <functional>
19#include <vector>
20
21#include "test_macros.h"
22#include "MoveOnly.h"
23#include "test_allocator.h"
24
25struct ThrowingDtorComp {
26 bool operator()(const auto&, const auto&) const;
27 ~ThrowingDtorComp() noexcept(false) {}
28};
29
30void test() {
31 {
32 using C = std::flat_set<MoveOnly, MoveOnly>;
33 static_assert(std::is_nothrow_destructible_v<C>);
34 C c;
35 }
36 {
37 using V = std::vector<MoveOnly, test_allocator<MoveOnly>>;
38 using C = std::flat_set<MoveOnly, std::less<MoveOnly>, V>;
39 static_assert(std::is_nothrow_destructible_v<C>);
40 C c;
41 }
42 {
43 using V = std::deque<MoveOnly, other_allocator<MoveOnly>>;
44 using C = std::flat_set<MoveOnly, std::greater<MoveOnly>, V>;
45 static_assert(std::is_nothrow_destructible_v<C>);
46 C c;
47 }
48#if defined(_LIBCPP_VERSION)
49 {
50 using C = std::flat_set<MoveOnly, ThrowingDtorComp>;
51 static_assert(!std::is_nothrow_destructible_v<C>);
52 C c;
53 }
54#endif // _LIBCPP_VERSION
55}
56
57int main(int, char**) {
58 test();
59
60 return 0;
61}
62

source code of libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/dtor_noexcept.pass.cpp