default_noexcept.pass.cpp revision d24c465beaec2fe9a0e365e6379cd5d3acaeb2ca
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_map() 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 "MoveOnly.h" 26#include "test_allocator.h" 27#include "../../../test_hash.h" 28 29template <class T> 30struct some_comp 31{ 32 typedef T value_type; 33 some_comp(); 34 some_comp(const some_comp&); 35 bool operator()(const T&, const T&) const { return false; } 36}; 37 38template <class T> 39struct some_hash 40{ 41 typedef T value_type; 42 some_hash(); 43 some_hash(const some_hash&); 44}; 45 46int main() 47{ 48 { 49 typedef std::unordered_map<MoveOnly, MoveOnly> C; 50 static_assert(std::is_nothrow_default_constructible<C>::value, ""); 51 } 52 { 53 typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, 54 std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; 55 static_assert(std::is_nothrow_default_constructible<C>::value, ""); 56 } 57 { 58 typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, 59 std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; 60 static_assert(!std::is_nothrow_default_constructible<C>::value, ""); 61 } 62 { 63 typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; 64 static_assert(!std::is_nothrow_default_constructible<C>::value, ""); 65 } 66 { 67 typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, 68 some_comp<MoveOnly>> C; 69 static_assert(!std::is_nothrow_default_constructible<C>::value, ""); 70 } 71} 72