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// <map>
10
11// multimap& operator=(multimap&& c)
12// noexcept(
13// allocator_type::propagate_on_container_move_assignment::value &&
14// is_nothrow_move_assignable<allocator_type>::value &&
15// is_nothrow_move_assignable<key_compare>::value);
16
17// This tests a conforming extension
18
19// UNSUPPORTED: c++03
20
21#include <map>
22
23#include "test_macros.h"
24#include "MoveOnly.h"
25#include "test_allocator.h"
26
27template <class T>
28struct some_comp {
29 using value_type = T;
30 some_comp& operator=(const some_comp&);
31 bool operator()(const T&, const T&) const { return false; }
32};
33
34template <class T>
35struct always_equal_alloc {
36 using value_type = T;
37 always_equal_alloc(const always_equal_alloc&);
38 void allocate(std::size_t);
39};
40
41template <class T>
42struct not_always_equal_alloc {
43 int i;
44 using value_type = T;
45 not_always_equal_alloc(const not_always_equal_alloc&);
46 void allocate(std::size_t);
47};
48
49template <template <class> class Alloc>
50using multimap_alloc =
51 std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, Alloc<std::pair<const MoveOnly, MoveOnly>>>;
52
53static_assert(std::is_nothrow_move_assignable<multimap_alloc<std::allocator>>::value, "");
54static_assert(!std::is_nothrow_move_assignable<multimap_alloc<test_allocator>>::value, "");
55#if TEST_STD_VER >= 17
56static_assert(std::is_nothrow_move_assignable<multimap_alloc<always_equal_alloc>>::value, "");
57#endif
58static_assert(!std::is_nothrow_move_assignable<multimap_alloc<not_always_equal_alloc>>::value, "");
59#if defined(_LIBCPP_VERSION)
60static_assert(std::is_nothrow_move_assignable<multimap_alloc<other_allocator>>::value, "");
61#endif // _LIBCPP_VERSION
62static_assert(!std::is_nothrow_move_assignable<std::multimap<int, int, some_comp<int>>>::value, "");
63

source code of libcxx/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.compile.pass.cpp