62 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <set>10 11// set& operator=(set&& 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 extension18 19// UNSUPPORTED: c++0320 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_map_alloc = std::set<MoveOnly, std::less<MoveOnly>, Alloc<MoveOnly>>;51 52static_assert(std::is_nothrow_move_assignable<unordered_map_alloc<std::allocator>>::value, "");53static_assert(!std::is_nothrow_move_assignable<unordered_map_alloc<test_allocator>>::value, "");54#if TEST_STD_VER >= 1755static_assert(std::is_nothrow_move_assignable<unordered_map_alloc<always_equal_alloc>>::value, "");56#endif57static_assert(!std::is_nothrow_move_assignable<unordered_map_alloc<not_always_equal_alloc>>::value, "");58#if defined(_LIBCPP_VERSION)59static_assert(std::is_nothrow_move_assignable<unordered_map_alloc<other_allocator>>::value, "");60#endif // _LIBCPP_VERSION61static_assert(!std::is_nothrow_move_assignable<std::set<int, some_comp<int>>>::value, "");62