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// <set>
10
11// multiset& operator=(multiset&& 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 <set>
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 unordered_set_alloc = std::set<MoveOnly, std::less<MoveOnly>, Alloc<MoveOnly>>;
51
52static_assert(std::is_nothrow_move_assignable<unordered_set_alloc<std::allocator>>::value, "");
53static_assert(!std::is_nothrow_move_assignable<unordered_set_alloc<test_allocator>>::value, "");
54#if TEST_STD_VER >= 17
55static_assert(std::is_nothrow_move_assignable<unordered_set_alloc<always_equal_alloc>>::value, "");
56#endif
57static_assert(!std::is_nothrow_move_assignable<unordered_set_alloc<not_always_equal_alloc>>::value, "");
58#if defined(_LIBCPP_VERSION)
59static_assert(std::is_nothrow_move_assignable<unordered_set_alloc<other_allocator>>::value, "");
60#endif // _LIBCPP_VERSION
61static_assert(!std::is_nothrow_move_assignable<std::set<int, some_comp<int>>>::value, "");
62

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