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