noexcept for <unordered_map>.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@132646 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant 2011-06-04 18:54:24 +00:00
parent 8b53768dac
commit 5f2f14c5d2
12 changed files with 1015 additions and 153 deletions

View File

@ -33,7 +33,7 @@ struct __hash_node_base
_NodePtr __next_; _NodePtr __next_;
_LIBCPP_INLINE_VISIBILITY __hash_node_base() : __next_(nullptr) {} _LIBCPP_INLINE_VISIBILITY __hash_node_base() _NOEXCEPT : __next_(nullptr) {}
}; };
template <class _Tp, class _VoidPtr> template <class _Tp, class _VoidPtr>
@ -80,7 +80,7 @@ public:
#endif #endif
pointer; pointer;
_LIBCPP_INLINE_VISIBILITY __hash_iterator() {} _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
reference operator*() const {return __node_->__value_;} reference operator*() const {return __node_->__value_;}
@ -111,7 +111,7 @@ public:
private: private:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__hash_iterator(__node_pointer __node) __hash_iterator(__node_pointer __node) _NOEXCEPT
: __node_(__node) : __node_(__node)
{} {}
@ -154,9 +154,9 @@ public:
__non_const_node_pointer; __non_const_node_pointer;
typedef __hash_iterator<__non_const_node_pointer> __non_const_iterator; typedef __hash_iterator<__non_const_node_pointer> __non_const_iterator;
_LIBCPP_INLINE_VISIBILITY __hash_const_iterator() {} _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__hash_const_iterator(const __non_const_iterator& __x) __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT
: __node_(__x.__node_) : __node_(__x.__node_)
{} {}
@ -189,7 +189,7 @@ public:
private: private:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__hash_const_iterator(__node_pointer __node) __hash_const_iterator(__node_pointer __node) _NOEXCEPT
: __node_(__node) : __node_(__node)
{} {}
@ -224,7 +224,7 @@ public:
#endif #endif
pointer; pointer;
_LIBCPP_INLINE_VISIBILITY __hash_local_iterator() {} _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
reference operator*() const {return __node_->__value_;} reference operator*() const {return __node_->__value_;}
@ -258,7 +258,7 @@ public:
private: private:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__hash_local_iterator(__node_pointer __node, size_t __bucket, __hash_local_iterator(__node_pointer __node, size_t __bucket,
size_t __bucket_count) size_t __bucket_count) _NOEXCEPT
: __node_(__node), : __node_(__node),
__bucket_(__bucket), __bucket_(__bucket),
__bucket_count_(__bucket_count) __bucket_count_(__bucket_count)
@ -308,9 +308,9 @@ public:
#endif #endif
pointer; pointer;
_LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() {} _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__hash_const_local_iterator(const __non_const_iterator& __x) __hash_const_local_iterator(const __non_const_iterator& __x) _NOEXCEPT
: __node_(__x.__node_), : __node_(__x.__node_),
__bucket_(__x.__bucket_), __bucket_(__x.__bucket_),
__bucket_count_(__x.__bucket_count_) __bucket_count_(__x.__bucket_count_)
@ -348,7 +348,7 @@ public:
private: private:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__hash_const_local_iterator(__node_pointer __node, size_t __bucket, __hash_const_local_iterator(__node_pointer __node, size_t __bucket,
size_t __bucket_count) size_t __bucket_count) _NOEXCEPT
: __node_(__node), : __node_(__node),
__bucket_(__bucket), __bucket_(__bucket),
__bucket_count_(__bucket_count) __bucket_count_(__bucket_count)
@ -374,16 +374,19 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__bucket_list_deallocator() __bucket_list_deallocator()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
: __data_(0) {} : __data_(0) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__bucket_list_deallocator(const allocator_type& __a, size_type __size) __bucket_list_deallocator(const allocator_type& __a, size_type __size)
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
: __data_(__size, __a) {} : __data_(__size, __a) {}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__bucket_list_deallocator(__bucket_list_deallocator&& __x) __bucket_list_deallocator(__bucket_list_deallocator&& __x)
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
: __data_(_STD::move(__x.__data_)) : __data_(_STD::move(__x.__data_))
{ {
__x.size() = 0; __x.size() = 0;
@ -391,14 +394,18 @@ public:
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY size_type& size() {return __data_.first();} _LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY size_type size() const {return __data_.first();} size_type& size() _NOEXCEPT {return __data_.first();}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY allocator_type& __alloc() {return __data_.second();} size_type size() const _NOEXCEPT {return __data_.first();}
_LIBCPP_INLINE_VISIBILITY const allocator_type& __alloc() const {return __data_.second();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void operator()(pointer __p) allocator_type& __alloc() _NOEXCEPT {return __data_.second();}
_LIBCPP_INLINE_VISIBILITY
const allocator_type& __alloc() const _NOEXCEPT {return __data_.second();}
_LIBCPP_INLINE_VISIBILITY
void operator()(pointer __p) _NOEXCEPT
{ {
__alloc_traits::deallocate(__alloc(), __p, size()); __alloc_traits::deallocate(__alloc(), __p, size());
} }
@ -424,13 +431,13 @@ public:
bool __value_constructed; bool __value_constructed;
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
explicit __hash_node_destructor(allocator_type& __na) explicit __hash_node_destructor(allocator_type& __na) _NOEXCEPT
: __na_(__na), : __na_(__na),
__value_constructed(false) __value_constructed(false)
{} {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void operator()(pointer __p) void operator()(pointer __p) _NOEXCEPT
{ {
if (__value_constructed) if (__value_constructed)
__alloc_traits::destroy(__na_, _STD::addressof(__p->__value_)); __alloc_traits::destroy(__na_, _STD::addressof(__p->__value_));
@ -495,21 +502,32 @@ private:
__compressed_pair<float, key_equal> __p3_; __compressed_pair<float, key_equal> __p3_;
// --- Member data end --- // --- Member data end ---
_LIBCPP_INLINE_VISIBILITY size_type& size() {return __p2_.first();} _LIBCPP_INLINE_VISIBILITY
size_type& size() _NOEXCEPT {return __p2_.first();}
public: public:
_LIBCPP_INLINE_VISIBILITY size_type size() const {return __p2_.first();} _LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT {return __p2_.first();}
_LIBCPP_INLINE_VISIBILITY hasher& hash_function() {return __p2_.second();} _LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY const hasher& hash_function() const {return __p2_.second();} hasher& hash_function() _NOEXCEPT {return __p2_.second();}
_LIBCPP_INLINE_VISIBILITY
const hasher& hash_function() const _NOEXCEPT {return __p2_.second();}
_LIBCPP_INLINE_VISIBILITY float& max_load_factor() {return __p3_.first();} _LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY float max_load_factor() const {return __p3_.first();} float& max_load_factor() _NOEXCEPT {return __p3_.first();}
_LIBCPP_INLINE_VISIBILITY
float max_load_factor() const _NOEXCEPT {return __p3_.first();}
_LIBCPP_INLINE_VISIBILITY key_equal& key_eq() {return __p3_.second();} _LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY const key_equal& key_eq() const {return __p3_.second();} key_equal& key_eq() _NOEXCEPT {return __p3_.second();}
_LIBCPP_INLINE_VISIBILITY
const key_equal& key_eq() const _NOEXCEPT {return __p3_.second();}
_LIBCPP_INLINE_VISIBILITY __node_allocator& __node_alloc() {return __p1_.second();} _LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY const __node_allocator& __node_alloc() const {return __p1_.second();} __node_allocator& __node_alloc() _NOEXCEPT {return __p1_.second();}
_LIBCPP_INLINE_VISIBILITY
const __node_allocator& __node_alloc() const _NOEXCEPT
{return __p1_.second();}
public: public:
typedef __hash_iterator<__node_pointer> iterator; typedef __hash_iterator<__node_pointer> iterator;
@ -517,7 +535,13 @@ public:
typedef __hash_local_iterator<__node_pointer> local_iterator; typedef __hash_local_iterator<__node_pointer> local_iterator;
typedef __hash_const_local_iterator<__node_const_pointer> const_local_iterator; typedef __hash_const_local_iterator<__node_const_pointer> const_local_iterator;
__hash_table(); __hash_table()
_NOEXCEPT_(
is_nothrow_default_constructible<__bucket_list>::value &&
is_nothrow_default_constructible<__first_node>::value &&
is_nothrow_default_constructible<__node_allocator>::value &&
is_nothrow_default_constructible<hasher>::value &&
is_nothrow_default_constructible<key_equal>::value);
__hash_table(const hasher& __hf, const key_equal& __eql); __hash_table(const hasher& __hf, const key_equal& __eql);
__hash_table(const hasher& __hf, const key_equal& __eql, __hash_table(const hasher& __hf, const key_equal& __eql,
const allocator_type& __a); const allocator_type& __a);
@ -525,14 +549,25 @@ public:
__hash_table(const __hash_table& __u); __hash_table(const __hash_table& __u);
__hash_table(const __hash_table& __u, const allocator_type& __a); __hash_table(const __hash_table& __u, const allocator_type& __a);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__hash_table(__hash_table&& __u); __hash_table(__hash_table&& __u)
_NOEXCEPT_(
is_nothrow_move_constructible<__bucket_list>::value &&
is_nothrow_move_constructible<__first_node>::value &&
is_nothrow_move_constructible<__node_allocator>::value &&
is_nothrow_move_constructible<hasher>::value &&
is_nothrow_move_constructible<key_equal>::value);
__hash_table(__hash_table&& __u, const allocator_type& __a); __hash_table(__hash_table&& __u, const allocator_type& __a);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~__hash_table(); ~__hash_table();
__hash_table& operator=(const __hash_table& __u); __hash_table& operator=(const __hash_table& __u);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__hash_table& operator=(__hash_table&& __u); __hash_table& operator=(__hash_table&& __u)
_NOEXCEPT_(
__node_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<__node_allocator>::value &&
is_nothrow_move_assignable<hasher>::value &&
is_nothrow_move_assignable<key_equal>::value);
#endif #endif
template <class _InputIterator> template <class _InputIterator>
void __assign_unique(_InputIterator __first, _InputIterator __last); void __assign_unique(_InputIterator __first, _InputIterator __last);
@ -540,7 +575,7 @@ public:
void __assign_multi(_InputIterator __first, _InputIterator __last); void __assign_multi(_InputIterator __first, _InputIterator __last);
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type max_size() const size_type max_size() const _NOEXCEPT
{ {
return allocator_traits<__pointer_allocator>::max_size( return allocator_traits<__pointer_allocator>::max_size(
__bucket_list_.get_deleter().__alloc()); __bucket_list_.get_deleter().__alloc());
@ -577,21 +612,21 @@ public:
iterator __insert_multi(const_iterator __p, const value_type& __x); iterator __insert_multi(const_iterator __p, const value_type& __x);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
void clear(); void clear() _NOEXCEPT;
void rehash(size_type __n); void rehash(size_type __n);
_LIBCPP_INLINE_VISIBILITY void reserve(size_type __n) _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n)
{rehash(static_cast<size_type>(ceil(__n / max_load_factor())));} {rehash(static_cast<size_type>(ceil(__n / max_load_factor())));}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type bucket_count() const size_type bucket_count() const _NOEXCEPT
{ {
return __bucket_list_.get_deleter().size(); return __bucket_list_.get_deleter().size();
} }
iterator begin(); iterator begin() _NOEXCEPT;
iterator end(); iterator end() _NOEXCEPT;
const_iterator begin() const; const_iterator begin() const _NOEXCEPT;
const_iterator end() const; const_iterator end() const _NOEXCEPT;
template <class _Key> template <class _Key>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@ -612,7 +647,7 @@ public:
size_type __erase_unique(const _Key& __k); size_type __erase_unique(const _Key& __k);
template <class _Key> template <class _Key>
size_type __erase_multi(const _Key& __k); size_type __erase_multi(const _Key& __k);
__node_holder remove(const_iterator __p); __node_holder remove(const_iterator __p) _NOEXCEPT;
template <class _Key> template <class _Key>
size_type __count_unique(const _Key& __k) const; size_type __count_unique(const _Key& __k) const;
@ -633,18 +668,25 @@ public:
pair<const_iterator, const_iterator> pair<const_iterator, const_iterator>
__equal_range_multi(const _Key& __k) const; __equal_range_multi(const _Key& __k) const;
void swap(__hash_table& __u); void swap(__hash_table& __u)
_NOEXCEPT_(
(!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
__is_nothrow_swappable<__pointer_allocator>::value) &&
(!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value) &&
__is_nothrow_swappable<hasher>::value &&
__is_nothrow_swappable<key_equal>::value);
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type max_bucket_count() const size_type max_bucket_count() const _NOEXCEPT
{return __bucket_list_.get_deleter().__alloc().max_size();} {return __bucket_list_.get_deleter().__alloc().max_size();}
size_type bucket_size(size_type __n) const; size_type bucket_size(size_type __n) const;
_LIBCPP_INLINE_VISIBILITY float load_factor() const _LIBCPP_INLINE_VISIBILITY float load_factor() const _NOEXCEPT
{ {
size_type __bc = bucket_count(); size_type __bc = bucket_count();
return __bc != 0 ? (float)size() / __bc : 0.f; return __bc != 0 ? (float)size() / __bc : 0.f;
} }
_LIBCPP_INLINE_VISIBILITY void max_load_factor(float __mlf) _LIBCPP_INLINE_VISIBILITY void max_load_factor(float __mlf) _NOEXCEPT
{max_load_factor() = _STD::max(__mlf, load_factor());} {max_load_factor() = _STD::max(__mlf, load_factor());}
_LIBCPP_INLINE_VISIBILITY local_iterator begin(size_type __n) _LIBCPP_INLINE_VISIBILITY local_iterator begin(size_type __n)
@ -678,25 +720,40 @@ private:
void __copy_assign_alloc(const __hash_table& __u, false_type) {} void __copy_assign_alloc(const __hash_table& __u, false_type) {}
void __move_assign(__hash_table& __u, false_type); void __move_assign(__hash_table& __u, false_type);
void __move_assign(__hash_table& __u, true_type); void __move_assign(__hash_table& __u, true_type)
_LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__hash_table& __u) _NOEXCEPT_(
is_nothrow_move_assignable<__node_allocator>::value &&
is_nothrow_move_assignable<hasher>::value &&
is_nothrow_move_assignable<key_equal>::value);
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__hash_table& __u)
_NOEXCEPT_(
!__node_traits::propagate_on_container_move_assignment::value ||
(is_nothrow_move_assignable<__pointer_allocator>::value &&
is_nothrow_move_assignable<__node_allocator>::value))
{__move_assign_alloc(__u, integral_constant<bool, {__move_assign_alloc(__u, integral_constant<bool,
__node_traits::propagate_on_container_move_assignment::value>());} __node_traits::propagate_on_container_move_assignment::value>());}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__hash_table& __u, true_type) void __move_assign_alloc(__hash_table& __u, true_type)
_NOEXCEPT_(
is_nothrow_move_assignable<__pointer_allocator>::value &&
is_nothrow_move_assignable<__node_allocator>::value)
{ {
__bucket_list_.get_deleter().__alloc() = __bucket_list_.get_deleter().__alloc() =
_STD::move(__u.__bucket_list_.get_deleter().__alloc()); _STD::move(__u.__bucket_list_.get_deleter().__alloc());
__node_alloc() = _STD::move(__u.__node_alloc()); __node_alloc() = _STD::move(__u.__node_alloc());
} }
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__hash_table&, false_type) {} void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {}
template <class _A> template <class _A>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
static static
void void
__swap_alloc(_A& __x, _A& __y) __swap_alloc(_A& __x, _A& __y)
_NOEXCEPT_(
!allocator_traits<_A>::propagate_on_container_swap::value ||
__is_nothrow_swappable<_A>::value)
{ {
__swap_alloc(__x, __y, __swap_alloc(__x, __y,
integral_constant<bool, integral_constant<bool,
@ -709,6 +766,7 @@ private:
static static
void void
__swap_alloc(_A& __x, _A& __y, true_type) __swap_alloc(_A& __x, _A& __y, true_type)
_NOEXCEPT_(__is_nothrow_swappable<_A>::value)
{ {
using _STD::swap; using _STD::swap;
swap(__x, __y); swap(__x, __y);
@ -718,15 +776,20 @@ private:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
static static
void void
__swap_alloc(_A& __x, _A& __y, false_type) {} __swap_alloc(_A& __x, _A& __y, false_type) _NOEXCEPT {}
void __deallocate(__node_pointer __np); void __deallocate(__node_pointer __np) _NOEXCEPT;
__node_pointer __detach(); __node_pointer __detach() _NOEXCEPT;
}; };
template <class _Tp, class _Hash, class _Equal, class _Alloc> template <class _Tp, class _Hash, class _Equal, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table() __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table()
_NOEXCEPT_(
is_nothrow_default_constructible<__bucket_list>::value &&
is_nothrow_default_constructible<__first_node>::value &&
is_nothrow_default_constructible<hasher>::value &&
is_nothrow_default_constructible<key_equal>::value)
: __p2_(0), : __p2_(0),
__p3_(1.0f) __p3_(1.0f)
{ {
@ -790,6 +853,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u,
template <class _Tp, class _Hash, class _Equal, class _Alloc> template <class _Tp, class _Hash, class _Equal, class _Alloc>
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u)
_NOEXCEPT_(
is_nothrow_move_constructible<__bucket_list>::value &&
is_nothrow_move_constructible<__first_node>::value &&
is_nothrow_move_constructible<hasher>::value &&
is_nothrow_move_constructible<key_equal>::value)
: __bucket_list_(_STD::move(__u.__bucket_list_)), : __bucket_list_(_STD::move(__u.__bucket_list_)),
__p1_(_STD::move(__u.__p1_)), __p1_(_STD::move(__u.__p1_)),
__p2_(_STD::move(__u.__p2_)), __p2_(_STD::move(__u.__p2_)),
@ -870,6 +938,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(const __hash_table& __u)
template <class _Tp, class _Hash, class _Equal, class _Alloc> template <class _Tp, class _Hash, class _Equal, class _Alloc>
void void
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate(__node_pointer __np) __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate(__node_pointer __np)
_NOEXCEPT
{ {
__node_allocator& __na = __node_alloc(); __node_allocator& __na = __node_alloc();
while (__np != nullptr) while (__np != nullptr)
@ -883,7 +952,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate(__node_pointer __np)
template <class _Tp, class _Hash, class _Equal, class _Alloc> template <class _Tp, class _Hash, class _Equal, class _Alloc>
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_pointer typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_pointer
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() __hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT
{ {
size_type __bc = bucket_count(); size_type __bc = bucket_count();
for (size_type __i = 0; __i < __bc; ++__i) for (size_type __i = 0; __i < __bc; ++__i)
@ -900,6 +969,10 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>
void void
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
__hash_table& __u, true_type) __hash_table& __u, true_type)
_NOEXCEPT_(
is_nothrow_move_assignable<__node_allocator>::value &&
is_nothrow_move_assignable<hasher>::value &&
is_nothrow_move_assignable<key_equal>::value)
{ {
clear(); clear();
__bucket_list_.reset(__u.__bucket_list_.release()); __bucket_list_.reset(__u.__bucket_list_.release());
@ -972,6 +1045,11 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
__hash_table<_Tp, _Hash, _Equal, _Alloc>& __hash_table<_Tp, _Hash, _Equal, _Alloc>&
__hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u) __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u)
_NOEXCEPT_(
__node_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<__node_allocator>::value &&
is_nothrow_move_assignable<hasher>::value &&
is_nothrow_move_assignable<key_equal>::value)
{ {
__move_assign(__u, integral_constant<bool, __move_assign(__u, integral_constant<bool,
__node_traits::propagate_on_container_move_assignment::value>()); __node_traits::propagate_on_container_move_assignment::value>());
@ -1051,7 +1129,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first,
template <class _Tp, class _Hash, class _Equal, class _Alloc> template <class _Tp, class _Hash, class _Equal, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT
{ {
return iterator(__p1_.first().__next_); return iterator(__p1_.first().__next_);
} }
@ -1059,7 +1137,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin()
template <class _Tp, class _Hash, class _Equal, class _Alloc> template <class _Tp, class _Hash, class _Equal, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT
{ {
return iterator(nullptr); return iterator(nullptr);
} }
@ -1067,7 +1145,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::end()
template <class _Tp, class _Hash, class _Equal, class _Alloc> template <class _Tp, class _Hash, class _Equal, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT
{ {
return const_iterator(__p1_.first().__next_); return const_iterator(__p1_.first().__next_);
} }
@ -1075,14 +1153,14 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const
template <class _Tp, class _Hash, class _Equal, class _Alloc> template <class _Tp, class _Hash, class _Equal, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT
{ {
return const_iterator(nullptr); return const_iterator(nullptr);
} }
template <class _Tp, class _Hash, class _Equal, class _Alloc> template <class _Tp, class _Hash, class _Equal, class _Alloc>
void void
__hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() __hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() _NOEXCEPT
{ {
if (size() > 0) if (size() > 0)
{ {
@ -1645,7 +1723,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__erase_multi(const _Key& __k)
template <class _Tp, class _Hash, class _Equal, class _Alloc> template <class _Tp, class _Hash, class _Equal, class _Alloc>
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
__hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
{ {
// current node // current node
__node_pointer __cn = const_cast<__node_pointer>(__p.__node_); __node_pointer __cn = const_cast<__node_pointer>(__p.__node_);
@ -1776,6 +1854,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(
template <class _Tp, class _Hash, class _Equal, class _Alloc> template <class _Tp, class _Hash, class _Equal, class _Alloc>
void void
__hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
_NOEXCEPT_(
(!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
__is_nothrow_swappable<__pointer_allocator>::value) &&
(!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value) &&
__is_nothrow_swappable<hasher>::value &&
__is_nothrow_swappable<key_equal>::value)
{ {
{ {
__node_pointer_pointer __npp = __bucket_list_.release(); __node_pointer_pointer __npp = __bucket_list_.release();
@ -1814,6 +1899,16 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::bucket_size(size_type __n) const
return __r; return __r;
} }
template <class _Tp, class _Hash, class _Equal, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x,
__hash_table<_Tp, _Hash, _Equal, _Alloc>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{
__x.swap(__y);
}
_LIBCPP_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP__HASH_TABLE #endif // _LIBCPP__HASH_TABLE

View File

@ -44,7 +44,12 @@ public:
typedef /unspecified/ local_iterator; typedef /unspecified/ local_iterator;
typedef /unspecified/ const_local_iterator; typedef /unspecified/ const_local_iterator;
explicit unordered_map(size_type n = 0, const hasher& hf = hasher(), unordered_map()
noexcept(
is_nothrow_default_constructible<hasher>::value &&
is_nothrow_default_constructible<key_equal>::value &&
is_nothrow_default_constructible<allocator_type>::value);
explicit unordered_map(size_type n, const hasher& hf = hasher(),
const key_equal& eql = key_equal(), const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type()); const allocator_type& a = allocator_type());
template <class InputIterator> template <class InputIterator>
@ -55,28 +60,37 @@ public:
explicit unordered_map(const allocator_type&); explicit unordered_map(const allocator_type&);
unordered_map(const unordered_map&); unordered_map(const unordered_map&);
unordered_map(const unordered_map&, const Allocator&); unordered_map(const unordered_map&, const Allocator&);
unordered_map(unordered_map&&); unordered_map(unordered_map&&)
noexcept(
is_nothrow_move_constructible<hasher>::value &&
is_nothrow_move_constructible<key_equal>::value &&
is_nothrow_move_constructible<allocator_type>::value);
unordered_map(unordered_map&&, const Allocator&); unordered_map(unordered_map&&, const Allocator&);
unordered_map(initializer_list<value_type>, size_type n = 0, unordered_map(initializer_list<value_type>, size_type n = 0,
const hasher& hf = hasher(), const key_equal& eql = key_equal(), const hasher& hf = hasher(), const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type()); const allocator_type& a = allocator_type());
~unordered_map(); ~unordered_map();
unordered_map& operator=(const unordered_map&); unordered_map& operator=(const unordered_map&);
unordered_map& operator=(unordered_map&&); unordered_map& operator=(unordered_map&&)
noexcept(
allocator_type::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value &&
is_nothrow_move_assignable<hasher>::value &&
is_nothrow_move_assignable<key_equal>::value);
unordered_map& operator=(initializer_list<value_type>); unordered_map& operator=(initializer_list<value_type>);
allocator_type get_allocator() const; allocator_type get_allocator() const noexcept;
bool empty() const; bool empty() const noexcept;
size_type size() const; size_type size() const noexcept;
size_type max_size() const; size_type max_size() const noexcept;
iterator begin(); iterator begin() noexcept;
iterator end(); iterator end() noexcept;
const_iterator begin() const; const_iterator begin() const noexcept;
const_iterator end() const; const_iterator end() const noexcept;
const_iterator cbegin() const; const_iterator cbegin() const noexcept;
const_iterator cend() const; const_iterator cend() const noexcept;
template <class... Args> template <class... Args>
pair<iterator, bool> emplace(Args&&... args); pair<iterator, bool> emplace(Args&&... args);
@ -95,9 +109,14 @@ public:
iterator erase(const_iterator position); iterator erase(const_iterator position);
size_type erase(const key_type& k); size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last); iterator erase(const_iterator first, const_iterator last);
void clear(); void clear() noexcept;
void swap(unordered_map&); void swap(unordered_map&)
noexcept(
(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value) &&
__is_nothrow_swappable<hasher>::value &&
__is_nothrow_swappable<key_equal>::value);
hasher hash_function() const; hasher hash_function() const;
key_equal key_eq() const; key_equal key_eq() const;
@ -114,8 +133,8 @@ public:
mapped_type& at(const key_type& k); mapped_type& at(const key_type& k);
const mapped_type& at(const key_type& k) const; const mapped_type& at(const key_type& k) const;
size_type bucket_count() const; size_type bucket_count() const noexcept;
size_type max_bucket_count() const; size_type max_bucket_count() const noexcept;
size_type bucket_size(size_type n) const; size_type bucket_size(size_type n) const;
size_type bucket(const key_type& k) const; size_type bucket(const key_type& k) const;
@ -127,8 +146,8 @@ public:
const_local_iterator cbegin(size_type n) const; const_local_iterator cbegin(size_type n) const;
const_local_iterator cend(size_type n) const; const_local_iterator cend(size_type n) const;
float load_factor() const; float load_factor() const noexcept;
float max_load_factor() const; float max_load_factor() const noexcept;
void max_load_factor(float z); void max_load_factor(float z);
void rehash(size_type n); void rehash(size_type n);
void reserve(size_type n); void reserve(size_type n);
@ -136,7 +155,8 @@ public:
template <class Key, class T, class Hash, class Pred, class Alloc> template <class Key, class T, class Hash, class Pred, class Alloc>
void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x, void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x,
unordered_map<Key, T, Hash, Pred, Alloc>& y); unordered_map<Key, T, Hash, Pred, Alloc>& y)
noexcept(noexcept(x.swap(y)));
template <class Key, class T, class Hash, class Pred, class Alloc> template <class Key, class T, class Hash, class Pred, class Alloc>
bool bool
@ -172,7 +192,12 @@ public:
typedef /unspecified/ local_iterator; typedef /unspecified/ local_iterator;
typedef /unspecified/ const_local_iterator; typedef /unspecified/ const_local_iterator;
explicit unordered_multimap(size_type n = 0, const hasher& hf = hasher(), unordered_multimap()
noexcept(
is_nothrow_default_constructible<hasher>::value &&
is_nothrow_default_constructible<key_equal>::value &&
is_nothrow_default_constructible<allocator_type>::value);
explicit unordered_multimap(size_type n, const hasher& hf = hasher(),
const key_equal& eql = key_equal(), const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type()); const allocator_type& a = allocator_type());
template <class InputIterator> template <class InputIterator>
@ -183,28 +208,37 @@ public:
explicit unordered_multimap(const allocator_type&); explicit unordered_multimap(const allocator_type&);
unordered_multimap(const unordered_multimap&); unordered_multimap(const unordered_multimap&);
unordered_multimap(const unordered_multimap&, const Allocator&); unordered_multimap(const unordered_multimap&, const Allocator&);
unordered_multimap(unordered_multimap&&); unordered_multimap(unordered_multimap&&)
noexcept(
is_nothrow_move_constructible<hasher>::value &&
is_nothrow_move_constructible<key_equal>::value &&
is_nothrow_move_constructible<allocator_type>::value);
unordered_multimap(unordered_multimap&&, const Allocator&); unordered_multimap(unordered_multimap&&, const Allocator&);
unordered_multimap(initializer_list<value_type>, size_type n = 0, unordered_multimap(initializer_list<value_type>, size_type n = 0,
const hasher& hf = hasher(), const key_equal& eql = key_equal(), const hasher& hf = hasher(), const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type()); const allocator_type& a = allocator_type());
~unordered_multimap(); ~unordered_multimap();
unordered_multimap& operator=(const unordered_multimap&); unordered_multimap& operator=(const unordered_multimap&);
unordered_multimap& operator=(unordered_multimap&&); unordered_multimap& operator=(unordered_multimap&&)
noexcept(
allocator_type::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value &&
is_nothrow_move_assignable<hasher>::value &&
is_nothrow_move_assignable<key_equal>::value);
unordered_multimap& operator=(initializer_list<value_type>); unordered_multimap& operator=(initializer_list<value_type>);
allocator_type get_allocator() const; allocator_type get_allocator() const noexcept;
bool empty() const; bool empty() const noexcept;
size_type size() const; size_type size() const noexcept;
size_type max_size() const; size_type max_size() const noexcept;
iterator begin(); iterator begin() noexcept;
iterator end(); iterator end() noexcept;
const_iterator begin() const; const_iterator begin() const noexcept;
const_iterator end() const; const_iterator end() const noexcept;
const_iterator cbegin() const; const_iterator cbegin() const noexcept;
const_iterator cend() const; const_iterator cend() const noexcept;
template <class... Args> template <class... Args>
iterator emplace(Args&&... args); iterator emplace(Args&&... args);
@ -223,9 +257,14 @@ public:
iterator erase(const_iterator position); iterator erase(const_iterator position);
size_type erase(const key_type& k); size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last); iterator erase(const_iterator first, const_iterator last);
void clear(); void clear() noexcept;
void swap(unordered_multimap&); void swap(unordered_multimap&)
noexcept(
(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value) &&
__is_nothrow_swappable<hasher>::value &&
__is_nothrow_swappable<key_equal>::value);
hasher hash_function() const; hasher hash_function() const;
key_equal key_eq() const; key_equal key_eq() const;
@ -236,8 +275,8 @@ public:
pair<iterator, iterator> equal_range(const key_type& k); pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const; pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
size_type bucket_count() const; size_type bucket_count() const noexcept;
size_type max_bucket_count() const; size_type max_bucket_count() const noexcept;
size_type bucket_size(size_type n) const; size_type bucket_size(size_type n) const;
size_type bucket(const key_type& k) const; size_type bucket(const key_type& k) const;
@ -249,8 +288,8 @@ public:
const_local_iterator cbegin(size_type n) const; const_local_iterator cbegin(size_type n) const;
const_local_iterator cend(size_type n) const; const_local_iterator cend(size_type n) const;
float load_factor() const; float load_factor() const noexcept;
float max_load_factor() const; float max_load_factor() const noexcept;
void max_load_factor(float z); void max_load_factor(float z);
void rehash(size_type n); void rehash(size_type n);
void reserve(size_type n); void reserve(size_type n);
@ -258,7 +297,8 @@ public:
template <class Key, class T, class Hash, class Pred, class Alloc> template <class Key, class T, class Hash, class Pred, class Alloc>
void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x, void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
unordered_multimap<Key, T, Hash, Pred, Alloc>& y); unordered_multimap<Key, T, Hash, Pred, Alloc>& y)
noexcept(noexcept(x.swap(y)));
template <class Key, class T, class Hash, class Pred, class Alloc> template <class Key, class T, class Hash, class Pred, class Alloc>
bool bool
@ -289,11 +329,15 @@ class __unordered_map_hasher
{ {
public: public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__unordered_map_hasher() : _Hash() {} __unordered_map_hasher()
_NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
: _Hash() {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__unordered_map_hasher(const _Hash& __h) : _Hash(__h) {} __unordered_map_hasher(const _Hash& __h)
_NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
: _Hash(__h) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
const _Hash& hash_function() const {return *this;} const _Hash& hash_function() const _NOEXCEPT {return *this;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_t operator()(const _Tp& __x) const size_t operator()(const _Tp& __x) const
{return static_cast<const _Hash&>(*this)(__x.first);} {return static_cast<const _Hash&>(*this)(__x.first);}
@ -308,11 +352,15 @@ class __unordered_map_hasher<_Tp, _Hash, false>
_Hash __hash_; _Hash __hash_;
public: public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__unordered_map_hasher() : __hash_() {} __unordered_map_hasher()
_NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
: __hash_() {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__unordered_map_hasher(const _Hash& __h) : __hash_(__h) {} __unordered_map_hasher(const _Hash& __h)
_NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
: __hash_(__h) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
const _Hash& hash_function() const {return __hash_;} const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_t operator()(const _Tp& __x) const size_t operator()(const _Tp& __x) const
{return __hash_(__x.first);} {return __hash_(__x.first);}
@ -327,11 +375,15 @@ class __unordered_map_equal
{ {
public: public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__unordered_map_equal() : _Pred() {} __unordered_map_equal()
_NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
: _Pred() {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__unordered_map_equal(const _Pred& __p) : _Pred(__p) {} __unordered_map_equal(const _Pred& __p)
_NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
: _Pred(__p) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
const _Pred& key_eq() const {return *this;} const _Pred& key_eq() const _NOEXCEPT {return *this;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const bool operator()(const _Tp& __x, const _Tp& __y) const
{return static_cast<const _Pred&>(*this)(__x.first, __y.first);} {return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
@ -353,11 +405,15 @@ class __unordered_map_equal<_Tp, _Pred, false>
_Pred __pred_; _Pred __pred_;
public: public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__unordered_map_equal() : __pred_() {} __unordered_map_equal()
_NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
: __pred_() {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__unordered_map_equal(const _Pred& __p) : __pred_(__p) {} __unordered_map_equal(const _Pred& __p)
_NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
: __pred_(__p) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
const _Pred& key_eq() const {return __pred_;} const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const bool operator()(const _Tp& __x, const _Tp& __y) const
{return __pred_(__x.first, __y.first);} {return __pred_(__x.first, __y.first);}
@ -394,7 +450,7 @@ public:
bool __second_constructed; bool __second_constructed;
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
explicit __hash_map_node_destructor(allocator_type& __na) explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT
: __na_(__na), : __na_(__na),
__first_constructed(false), __first_constructed(false),
__second_constructed(false) __second_constructed(false)
@ -403,6 +459,7 @@ public:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x) __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
_NOEXCEPT
: __na_(__x.__na_), : __na_(__x.__na_),
__first_constructed(__x.__value_constructed), __first_constructed(__x.__value_constructed),
__second_constructed(__x.__value_constructed) __second_constructed(__x.__value_constructed)
@ -421,7 +478,7 @@ public:
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void operator()(pointer __p) void operator()(pointer __p) _NOEXCEPT
{ {
if (__second_constructed) if (__second_constructed)
__alloc_traits::destroy(__na_, _STD::addressof(__p->__value_.second)); __alloc_traits::destroy(__na_, _STD::addressof(__p->__value_.second));
@ -454,10 +511,10 @@ public:
pointer; pointer;
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__hash_map_iterator() {} __hash_map_iterator() _NOEXCEPT {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__hash_map_iterator(_HashIterator __i) : __i_(__i) {} __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
reference operator*() const {return *operator->();} reference operator*() const {return *operator->();}
@ -510,13 +567,14 @@ public:
pointer; pointer;
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__hash_map_const_iterator() {} __hash_map_const_iterator() _NOEXCEPT {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__hash_map_const_iterator(_HashIterator __i) : __i_(__i) {} __hash_map_const_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__hash_map_const_iterator( __hash_map_const_iterator(
__hash_map_iterator<typename _HashIterator::__non_const_iterator> __i) __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i)
_NOEXCEPT
: __i_(__i.__i_) {} : __i_(__i.__i_) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@ -599,7 +657,9 @@ public:
typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator; typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
unordered_map() {} // = default; unordered_map()
_NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
{} // = default;
explicit unordered_map(size_type __n, const hasher& __hf = hasher(), explicit unordered_map(size_type __n, const hasher& __hf = hasher(),
const key_equal& __eql = key_equal()); const key_equal& __eql = key_equal());
unordered_map(size_type __n, const hasher& __hf, unordered_map(size_type __n, const hasher& __hf,
@ -620,7 +680,8 @@ public:
unordered_map(const unordered_map& __u); unordered_map(const unordered_map& __u);
unordered_map(const unordered_map& __u, const allocator_type& __a); unordered_map(const unordered_map& __u, const allocator_type& __a);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
unordered_map(unordered_map&& __u); unordered_map(unordered_map&& __u)
_NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
unordered_map(unordered_map&& __u, const allocator_type& __a); unordered_map(unordered_map&& __u, const allocator_type& __a);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
unordered_map(initializer_list<value_type> __il); unordered_map(initializer_list<value_type> __il);
@ -632,33 +693,34 @@ public:
// ~unordered_map() = default; // ~unordered_map() = default;
// unordered_map& operator=(const unordered_map& __u) = default; // unordered_map& operator=(const unordered_map& __u) = default;
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
unordered_map& operator=(unordered_map&& __u); unordered_map& operator=(unordered_map&& __u)
_NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
#endif #endif
unordered_map& operator=(initializer_list<value_type> __il); unordered_map& operator=(initializer_list<value_type> __il);
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
allocator_type get_allocator() const allocator_type get_allocator() const _NOEXCEPT
{return allocator_type(__table_.__node_alloc());} {return allocator_type(__table_.__node_alloc());}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
bool empty() const {return __table_.size() == 0;} bool empty() const _NOEXCEPT {return __table_.size() == 0;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type size() const {return __table_.size();} size_type size() const _NOEXCEPT {return __table_.size();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type max_size() const {return __table_.max_size();} size_type max_size() const _NOEXCEPT {return __table_.max_size();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
iterator begin() {return __table_.begin();} iterator begin() _NOEXCEPT {return __table_.begin();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
iterator end() {return __table_.end();} iterator end() _NOEXCEPT {return __table_.end();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
const_iterator begin() const {return __table_.begin();} const_iterator begin() const _NOEXCEPT {return __table_.begin();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
const_iterator end() const {return __table_.end();} const_iterator end() const _NOEXCEPT {return __table_.end();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
const_iterator cbegin() const {return __table_.begin();} const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
const_iterator cend() const {return __table_.end();} const_iterator cend() const _NOEXCEPT {return __table_.end();}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@ -733,10 +795,12 @@ public:
iterator erase(const_iterator __first, const_iterator __last) iterator erase(const_iterator __first, const_iterator __last)
{return __table_.erase(__first.__i_, __last.__i_);} {return __table_.erase(__first.__i_, __last.__i_);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void clear() {__table_.clear();} void clear() _NOEXCEPT {__table_.clear();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void swap(unordered_map& __u) {__table_.swap(__u.__table_);} void swap(unordered_map& __u)
_NOEXCEPT_(__is_nothrow_swappable<__table>::value)
{__table_.swap(__u.__table_);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
hasher hash_function() const hasher hash_function() const
@ -767,9 +831,9 @@ public:
const mapped_type& at(const key_type& __k) const; const mapped_type& at(const key_type& __k) const;
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type bucket_count() const {return __table_.bucket_count();} size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type max_bucket_count() const {return __table_.max_bucket_count();} size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type bucket_size(size_type __n) const size_type bucket_size(size_type __n) const
@ -791,9 +855,9 @@ public:
const_local_iterator cend(size_type __n) const {return __table_.cend(__n);} const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
float load_factor() const {return __table_.load_factor();} float load_factor() const _NOEXCEPT {return __table_.load_factor();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
float max_load_factor() const {return __table_.max_load_factor();} float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@ -895,6 +959,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
unordered_map&& __u) unordered_map&& __u)
_NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
: __table_(_STD::move(__u.__table_)) : __table_(_STD::move(__u.__table_))
{ {
} }
@ -949,6 +1014,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u) unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u)
_NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
{ {
__table_ = _STD::move(__u.__table_); __table_ = _STD::move(__u.__table_);
return *this; return *this;
@ -1111,6 +1177,7 @@ inline _LIBCPP_INLINE_VISIBILITY
void void
swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{ {
__x.swap(__y); __x.swap(__y);
} }
@ -1193,7 +1260,9 @@ public:
typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator; typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
unordered_multimap() {} // = default unordered_multimap()
_NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
{} // = default;
explicit unordered_multimap(size_type __n, const hasher& __hf = hasher(), explicit unordered_multimap(size_type __n, const hasher& __hf = hasher(),
const key_equal& __eql = key_equal()); const key_equal& __eql = key_equal());
unordered_multimap(size_type __n, const hasher& __hf, unordered_multimap(size_type __n, const hasher& __hf,
@ -1214,7 +1283,8 @@ public:
unordered_multimap(const unordered_multimap& __u); unordered_multimap(const unordered_multimap& __u);
unordered_multimap(const unordered_multimap& __u, const allocator_type& __a); unordered_multimap(const unordered_multimap& __u, const allocator_type& __a);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
unordered_multimap(unordered_multimap&& __u); unordered_multimap(unordered_multimap&& __u)
_NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
unordered_multimap(unordered_multimap&& __u, const allocator_type& __a); unordered_multimap(unordered_multimap&& __u, const allocator_type& __a);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
unordered_multimap(initializer_list<value_type> __il); unordered_multimap(initializer_list<value_type> __il);
@ -1227,33 +1297,34 @@ public:
// ~unordered_multimap() = default; // ~unordered_multimap() = default;
// unordered_multimap& operator=(const unordered_multimap& __u) = default; // unordered_multimap& operator=(const unordered_multimap& __u) = default;
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
unordered_multimap& operator=(unordered_multimap&& __u); unordered_multimap& operator=(unordered_multimap&& __u)
_NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
#endif #endif
unordered_multimap& operator=(initializer_list<value_type> __il); unordered_multimap& operator=(initializer_list<value_type> __il);
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
allocator_type get_allocator() const allocator_type get_allocator() const _NOEXCEPT
{return allocator_type(__table_.__node_alloc());} {return allocator_type(__table_.__node_alloc());}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
bool empty() const {return __table_.size() == 0;} bool empty() const _NOEXCEPT {return __table_.size() == 0;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type size() const {return __table_.size();} size_type size() const _NOEXCEPT {return __table_.size();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type max_size() const {return __table_.max_size();} size_type max_size() const _NOEXCEPT {return __table_.max_size();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
iterator begin() {return __table_.begin();} iterator begin() _NOEXCEPT {return __table_.begin();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
iterator end() {return __table_.end();} iterator end() _NOEXCEPT {return __table_.end();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
const_iterator begin() const {return __table_.begin();} const_iterator begin() const _NOEXCEPT {return __table_.begin();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
const_iterator end() const {return __table_.end();} const_iterator end() const _NOEXCEPT {return __table_.end();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
const_iterator cbegin() const {return __table_.begin();} const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
const_iterator cend() const {return __table_.end();} const_iterator cend() const _NOEXCEPT {return __table_.end();}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@ -1324,10 +1395,12 @@ public:
iterator erase(const_iterator __first, const_iterator __last) iterator erase(const_iterator __first, const_iterator __last)
{return __table_.erase(__first.__i_, __last.__i_);} {return __table_.erase(__first.__i_, __last.__i_);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void clear() {__table_.clear();} void clear() _NOEXCEPT {__table_.clear();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void swap(unordered_multimap& __u) {__table_.swap(__u.__table_);} void swap(unordered_multimap& __u)
_NOEXCEPT_(__is_nothrow_swappable<__table>::value)
{__table_.swap(__u.__table_);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
hasher hash_function() const hasher hash_function() const
@ -1350,9 +1423,10 @@ public:
{return __table_.__equal_range_multi(__k);} {return __table_.__equal_range_multi(__k);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type bucket_count() const {return __table_.bucket_count();} size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type max_bucket_count() const {return __table_.max_bucket_count();} size_type max_bucket_count() const _NOEXCEPT
{return __table_.max_bucket_count();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type bucket_size(size_type __n) const size_type bucket_size(size_type __n) const
@ -1374,9 +1448,9 @@ public:
const_local_iterator cend(size_type __n) const {return __table_.cend(__n);} const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
float load_factor() const {return __table_.load_factor();} float load_factor() const _NOEXCEPT {return __table_.load_factor();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
float max_load_factor() const {return __table_.max_load_factor();} float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@ -1474,6 +1548,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
unordered_multimap&& __u) unordered_multimap&& __u)
_NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
: __table_(_STD::move(__u.__table_)) : __table_(_STD::move(__u.__table_))
{ {
} }
@ -1530,6 +1605,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multimap&& __u) unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multimap&& __u)
_NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
{ {
__table_ = _STD::move(__u.__table_); __table_ = _STD::move(__u.__table_);
return *this; return *this;
@ -1637,6 +1713,7 @@ inline _LIBCPP_INLINE_VISIBILITY
void void
swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{ {
__x.swap(__y); __x.swap(__y);
} }

View File

@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// unordered_map()
// noexcept(
// is_nothrow_default_constructible<allocator_type>::value &&
// is_nothrow_default_constructible<key_compare>::value &&
// is_nothrow_copy_constructible<key_compare>::value);
// This tests a conforming extension
#include <unordered_map>
#include <cassert>
#include "../../../MoveOnly.h"
#include "../../../test_allocator.h"
#include "../../../test_hash.h"
template <class T>
struct some_comp
{
typedef T value_type;
some_comp();
some_comp(const some_comp&);
};
template <class T>
struct some_hash
{
typedef T value_type;
some_hash();
some_hash(const some_hash&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::unordered_map<MoveOnly, MoveOnly> C;
static_assert(std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
some_comp<MoveOnly>> C;
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
}
#endif
}

View File

@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// ~unordered_map() // implied noexcept;
#include <unordered_map>
#include <cassert>
#include "../../../MoveOnly.h"
#include "../../../test_allocator.h"
#if __has_feature(cxx_noexcept)
template <class T>
struct some_comp
{
typedef T value_type;
~some_comp() noexcept(false);
};
template <class T>
struct some_hash
{
typedef T value_type;
some_hash();
some_hash(const some_hash&);
~some_hash() noexcept(false);
};
#endif
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::unordered_map<MoveOnly, MoveOnly> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
static_assert(!std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
some_comp<MoveOnly>> C;
static_assert(!std::is_nothrow_destructible<C>::value, "");
}
#endif
}

View File

@ -0,0 +1,69 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// unordered_map& operator=(unordered_map&& c)
// noexcept(
// allocator_type::propagate_on_container_move_assignment::value &&
// is_nothrow_move_assignable<allocator_type>::value &&
// is_nothrow_move_assignable<key_compare>::value);
// This tests a conforming extension
#include <unordered_map>
#include <cassert>
#include "../../../MoveOnly.h"
#include "../../../test_allocator.h"
template <class T>
struct some_comp
{
typedef T value_type;
some_comp& operator=(const some_comp&);
};
template <class T>
struct some_hash
{
typedef T value_type;
some_hash();
some_hash(const some_hash&);
some_hash& operator=(const some_hash&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::unordered_map<MoveOnly, MoveOnly> C;
static_assert(std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
some_comp<MoveOnly>> C;
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
}
#endif
}

View File

@ -0,0 +1,66 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// unordered_map(unordered_map&&)
// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
// is_nothrow_move_constructible<key_compare>::value);
// This tests a conforming extension
#include <unordered_map>
#include <cassert>
#include "../../../MoveOnly.h"
#include "../../../test_allocator.h"
template <class T>
struct some_comp
{
typedef T value_type;
some_comp(const some_comp&);
};
template <class T>
struct some_hash
{
typedef T value_type;
some_hash();
some_hash(const some_hash&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::unordered_map<MoveOnly, MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
static_assert(!std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
some_comp<MoveOnly>> C;
static_assert(!std::is_nothrow_move_constructible<C>::value, "");
}
#endif
}

View File

@ -0,0 +1,73 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// void swap(unordered_map& c)
// noexcept(!allocator_type::propagate_on_container_swap::value ||
// __is_nothrow_swappable<allocator_type>::value);
// This tests a conforming extension
#include <unordered_map>
#include <cassert>
#include "../../../MoveOnly.h"
#include "../../../test_allocator.h"
template <class T>
struct some_comp
{
typedef T value_type;
some_comp() {}
some_comp(const some_comp&) {}
};
template <class T>
struct some_hash
{
typedef T value_type;
some_hash() {}
some_hash(const some_hash&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::unordered_map<MoveOnly, MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
}
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
some_comp<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
}
#endif
}

View File

@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// unordered_multimap()
// noexcept(
// is_nothrow_default_constructible<allocator_type>::value &&
// is_nothrow_default_constructible<key_compare>::value &&
// is_nothrow_copy_constructible<key_compare>::value);
// This tests a conforming extension
#include <unordered_map>
#include <cassert>
#include "../../../MoveOnly.h"
#include "../../../test_allocator.h"
#include "../../../test_hash.h"
template <class T>
struct some_comp
{
typedef T value_type;
some_comp();
some_comp(const some_comp&);
};
template <class T>
struct some_hash
{
typedef T value_type;
some_hash();
some_hash(const some_hash&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
static_assert(std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
some_comp<MoveOnly>> C;
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
}
#endif
}

View File

@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// ~unordered_multimap() // implied noexcept;
#include <unordered_map>
#include <cassert>
#include "../../../MoveOnly.h"
#include "../../../test_allocator.h"
#if __has_feature(cxx_noexcept)
template <class T>
struct some_comp
{
typedef T value_type;
~some_comp() noexcept(false);
};
template <class T>
struct some_hash
{
typedef T value_type;
some_hash();
some_hash(const some_hash&);
~some_hash() noexcept(false);
};
#endif
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
static_assert(!std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
some_comp<MoveOnly>> C;
static_assert(!std::is_nothrow_destructible<C>::value, "");
}
#endif
}

View File

@ -0,0 +1,69 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// unordered_multimap& operator=(unordered_multimap&& c)
// noexcept(
// allocator_type::propagate_on_container_move_assignment::value &&
// is_nothrow_move_assignable<allocator_type>::value &&
// is_nothrow_move_assignable<key_compare>::value);
// This tests a conforming extension
#include <unordered_map>
#include <cassert>
#include "../../../MoveOnly.h"
#include "../../../test_allocator.h"
template <class T>
struct some_comp
{
typedef T value_type;
some_comp& operator=(const some_comp&);
};
template <class T>
struct some_hash
{
typedef T value_type;
some_hash();
some_hash(const some_hash&);
some_hash& operator=(const some_hash&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
static_assert(std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
some_comp<MoveOnly>> C;
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
}
#endif
}

View File

@ -0,0 +1,66 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// unordered_multimap(unordered_multimap&&)
// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
// is_nothrow_move_constructible<key_compare>::value);
// This tests a conforming extension
#include <unordered_map>
#include <cassert>
#include "../../../MoveOnly.h"
#include "../../../test_allocator.h"
template <class T>
struct some_comp
{
typedef T value_type;
some_comp(const some_comp&);
};
template <class T>
struct some_hash
{
typedef T value_type;
some_hash();
some_hash(const some_hash&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
static_assert(!std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
some_comp<MoveOnly>> C;
static_assert(!std::is_nothrow_move_constructible<C>::value, "");
}
#endif
}

View File

@ -0,0 +1,73 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// void swap(unordered_multimap& c)
// noexcept(!allocator_type::propagate_on_container_swap::value ||
// __is_nothrow_swappable<allocator_type>::value);
// This tests a conforming extension
#include <unordered_map>
#include <cassert>
#include "../../../MoveOnly.h"
#include "../../../test_allocator.h"
template <class T>
struct some_comp
{
typedef T value_type;
some_comp() {}
some_comp(const some_comp&) {}
};
template <class T>
struct some_hash
{
typedef T value_type;
some_hash() {}
some_hash(const some_hash&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
}
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
some_comp<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
}
#endif
}