1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <unordered_set> 11 12 // unordered_set& operator=(unordered_set&& c) 13 // noexcept( 14 // allocator_type::propagate_on_container_move_assignment::value && 15 // is_nothrow_move_assignable<allocator_type>::value && 16 // is_nothrow_move_assignable<key_compare>::value); 17 18 // This tests a conforming extension 19 20 #include <unordered_set> 21 #include <cassert> 22 23 #include "../../../MoveOnly.h" 24 #include "test_allocator.h" 25 26 template <class T> 27 struct some_comp 28 { 29 typedef T value_type; 30 some_comp& operator=(const some_comp&); 31 }; 32 33 template <class T> 34 struct some_hash 35 { 36 typedef T value_type; 37 some_hash(); 38 some_hash(const some_hash&); 39 some_hash& operator=(const some_hash&); 40 }; 41 42 int main() 43 { 44 #if __has_feature(cxx_noexcept) 45 { 46 typedef std::unordered_set<MoveOnly> C; 47 static_assert(std::is_nothrow_move_assignable<C>::value, ""); 48 } 49 { 50 typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, 51 std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; 52 static_assert(!std::is_nothrow_move_assignable<C>::value, ""); 53 } 54 { 55 typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, 56 std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; 57 static_assert(std::is_nothrow_move_assignable<C>::value, ""); 58 } 59 { 60 typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C; 61 static_assert(!std::is_nothrow_move_assignable<C>::value, ""); 62 } 63 { 64 typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, 65 some_comp<MoveOnly>> C; 66 static_assert(!std::is_nothrow_move_assignable<C>::value, ""); 67 } 68 #endif 69 } 70