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_map>
12
13// flat_multimap()
14// noexcept(
15// is_nothrow_default_constructible_v<key_container_type> &&
16// is_nothrow_default_constructible_v<mapped_container_type> &&
17// is_nothrow_default_constructible_v<key_compare>);
18
19// This tests a conforming extension
20
21#include <cassert>
22#include <flat_map>
23#include <functional>
24#include <vector>
25
26#include "test_macros.h"
27#include "MoveOnly.h"
28#include "test_allocator.h"
29
30struct ThrowingCtorComp {
31 ThrowingCtorComp() noexcept(false) {}
32 bool operator()(const auto&, const auto&) const { return false; }
33};
34
35int main(int, char**) {
36#if defined(_LIBCPP_VERSION)
37 {
38 using C = std::flat_multimap<MoveOnly, MoveOnly>;
39 static_assert(std::is_nothrow_default_constructible_v<C>);
40 C c;
41 }
42 {
43 using C =
44 std::flat_multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, test_allocator<MoveOnly>>>;
45 static_assert(std::is_nothrow_default_constructible_v<C>);
46 C c;
47 }
48#endif // _LIBCPP_VERSION
49 {
50 using C =
51 std::flat_multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, other_allocator<MoveOnly>>>;
52 static_assert(!std::is_nothrow_default_constructible_v<C>);
53 C c;
54 }
55 {
56 using C = std::flat_multimap<MoveOnly, MoveOnly, ThrowingCtorComp>;
57 static_assert(!std::is_nothrow_default_constructible_v<C>);
58 C c;
59 }
60 return 0;
61}
62

source code of libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/default_noexcept.pass.cpp