move_noexcept.pass.cpp (2164B)
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_multiset(unordered_multiset&&) 13 // noexcept(is_nothrow_move_constructible<allocator_type>::value && 14 // is_nothrow_move_constructible<key_compare>::value); 15 16 // This tests a conforming extension 17 18 // UNSUPPORTED: c++98, c++03 19 20 #include <unordered_set> 21 #include <cassert> 22 23 #include "test_macros.h" 24 #include "MoveOnly.h" 25 #include "test_allocator.h" 26 27 template <class T> 28 struct some_comp 29 { 30 typedef T value_type; 31 some_comp(const some_comp&); 32 bool operator()(const T&, const T&) const { return false; } 33 }; 34 35 template <class T> 36 struct some_hash 37 { 38 typedef T value_type; 39 some_hash(); 40 some_hash(const some_hash&); 41 std::size_t operator()(T const&) const; 42 }; 43 44 int main() 45 { 46 #if defined(_LIBCPP_VERSION) 47 { 48 typedef std::unordered_multiset<MoveOnly> C; 49 static_assert(std::is_nothrow_move_constructible<C>::value, ""); 50 } 51 { 52 typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, 53 std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; 54 static_assert(std::is_nothrow_move_constructible<C>::value, ""); 55 } 56 { 57 typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, 58 std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; 59 static_assert(std::is_nothrow_move_constructible<C>::value, ""); 60 } 61 #endif // _LIBCPP_VERSION 62 { 63 typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C; 64 static_assert(!std::is_nothrow_move_constructible<C>::value, ""); 65 } 66 { 67 typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, 68 some_comp<MoveOnly>> C; 69 static_assert(!std::is_nothrow_move_constructible<C>::value, ""); 70 } 71 }