From 7a6b7cedcb3359ad7d77e355b02ab982d9d2b25b Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sat, 22 Jun 2013 15:21:29 +0000 Subject: [PATCH] Implement full support for non-pointer types in custom allocators. This is for the unordered containers only. This work still needs to be done on the sequence containers. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@184635 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/__hash_table | 56 ++-- include/unordered_map | 152 ++++++++-- lib/buildit | 4 +- .../unord/unord.map/bucket.pass.cpp | 23 ++ .../unord/unord.map/bucket_count.pass.cpp | 31 ++ .../unord/unord.map/bucket_size.pass.cpp | 25 ++ .../containers/unord/unord.map/count.pass.cpp | 23 ++ test/containers/unord/unord.map/eq.pass.cpp | 71 +++++ .../unord.map/equal_range_const.pass.cpp | 28 ++ .../unord.map/equal_range_non_const.pass.cpp | 28 ++ .../unord/unord.map/find_const.pass.cpp | 26 ++ .../unord/unord.map/find_non_const.pass.cpp | 26 ++ .../unord/unord.map/iterators.pass.cpp | 44 +++ .../unord/unord.map/load_factor.pass.cpp | 29 ++ .../unord/unord.map/local_iterators.pass.cpp | 200 +++++++++++++ .../unord/unord.map/max_bucket_count.pass.cpp | 12 + .../unord/unord.map/max_load_factor.pass.cpp | 20 ++ .../unord/unord.map/max_size.pass.cpp | 9 + .../unord/unord.map/rehash.pass.cpp | 34 ++- .../unord/unord.map/reserve.pass.cpp | 34 ++- .../unord/unord.map/swap_member.pass.cpp | 183 ++++++++++++ .../containers/unord/unord.map/types.pass.cpp | 20 ++ .../unord.map.cnstr/allocator.pass.cpp | 22 ++ .../unord.map.cnstr/assign_copy.pass.cpp | 48 ++++ .../unord.map.cnstr/assign_init.pass.cpp | 35 +++ .../unord.map.cnstr/assign_move.pass.cpp | 49 ++++ .../unord.map/unord.map.cnstr/copy.pass.cpp | 42 +++ .../unord.map.cnstr/copy_alloc.pass.cpp | 42 +++ .../unord.map.cnstr/default.pass.cpp | 22 ++ .../unord.map/unord.map.cnstr/init.pass.cpp | 34 +++ .../unord.map.cnstr/init_size.pass.cpp | 36 +++ .../unord.map.cnstr/init_size_hash.pass.cpp | 37 +++ .../init_size_hash_equal.pass.cpp | 38 +++ .../init_size_hash_equal_allocator.pass.cpp | 39 +++ .../unord.map/unord.map.cnstr/move.pass.cpp | 80 ++++++ .../unord.map.cnstr/move_alloc.pass.cpp | 44 +++ .../unord.map/unord.map.cnstr/range.pass.cpp | 36 +++ .../unord.map.cnstr/range_size.pass.cpp | 38 +++ .../unord.map.cnstr/range_size_hash.pass.cpp | 39 +++ .../range_size_hash_equal.pass.cpp | 40 +++ .../range_size_hash_equal_allocator.pass.cpp | 41 +++ .../unord.map/unord.map.cnstr/size.fail.cpp | 22 ++ .../unord.map/unord.map.cnstr/size.pass.cpp | 22 ++ .../unord.map.cnstr/size_hash.pass.cpp | 24 ++ .../unord.map.cnstr/size_hash_equal.pass.cpp | 25 ++ .../size_hash_equal_allocator.pass.cpp | 26 ++ .../unord.map/unord.map.elem/at.pass.cpp | 56 ++++ .../unord.map/unord.map.elem/index.pass.cpp | 47 ++++ .../unord.map.swap/swap_non_member.pass.cpp | 183 ++++++++++++ .../unorder.map.modifiers/clear.pass.cpp | 21 ++ .../unorder.map.modifiers/emplace.pass.cpp | 27 ++ .../emplace_hint.pass.cpp | 25 ++ .../erase_const_iter.pass.cpp | 25 ++ .../unorder.map.modifiers/erase_key.pass.cpp | 61 ++++ .../erase_range.pass.cpp | 40 +++ .../insert_const_lvalue.pass.cpp | 34 +++ .../insert_hint_const_lvalue.pass.cpp | 31 ++ .../insert_hint_rvalue.pass.cpp | 59 ++++ .../insert_init.pass.cpp | 24 ++ .../insert_range.pass.cpp | 24 ++ .../insert_rvalue.pass.cpp | 65 +++++ .../unord/unord.multimap/bucket.pass.cpp | 23 ++ .../unord/unord.multimap/bucket_size.pass.cpp | 27 ++ .../unord/unord.multimap/count.pass.cpp | 26 ++ .../unord/unord.multimap/eq.pass.cpp | 80 ++++++ .../unord.multimap/equal_range_const.pass.cpp | 39 +++ .../equal_range_non_const.pass.cpp | 39 +++ .../unord/unord.multimap/find_const.pass.cpp | 26 ++ .../unord.multimap/find_non_const.pass.cpp | 26 ++ .../unord/unord.multimap/iterators.pass.cpp | 47 ++++ .../unord/unord.multimap/load_factor.pass.cpp | 29 ++ .../unord.multimap/local_iterators.pass.cpp | 264 ++++++++++++++++++ .../unord.multimap/max_bucket_count.pass.cpp | 12 + .../unord.multimap/max_load_factor.pass.cpp | 20 ++ .../unord/unord.multimap/max_size.pass.cpp | 9 + .../unord/unord.multimap/rehash.pass.cpp | 39 ++- .../unord/unord.multimap/reserve.pass.cpp | 34 ++- .../unord/unord.multimap/swap_member.pass.cpp | 188 +++++++++++++ .../unord/unord.multimap/types.pass.cpp | 20 ++ .../unord.multimap.cnstr/allocator.pass.cpp | 22 ++ .../unord.multimap.cnstr/assign_copy.pass.cpp | 62 ++++ .../unord.multimap.cnstr/assign_init.pass.cpp | 59 ++++ .../unord.multimap.cnstr/assign_move.pass.cpp | 68 +++++ .../unord.multimap.cnstr/copy.pass.cpp | 56 ++++ .../unord.multimap.cnstr/copy_alloc.pass.cpp | 56 ++++ .../unord.multimap.cnstr/default.pass.cpp | 22 ++ .../unord.multimap.cnstr/init.pass.cpp | 56 ++++ .../unord.multimap.cnstr/init_size.pass.cpp | 58 ++++ .../init_size_hash.pass.cpp | 59 ++++ .../init_size_hash_equal.pass.cpp | 60 ++++ .../init_size_hash_equal_allocator.pass.cpp | 61 ++++ .../unord.multimap.cnstr/move.pass.cpp | 102 +++++++ .../unord.multimap.cnstr/move_alloc.pass.cpp | 67 +++++ .../unord.multimap.cnstr/range.pass.cpp | 58 ++++ .../unord.multimap.cnstr/range_size.pass.cpp | 60 ++++ .../range_size_hash.pass.cpp | 61 ++++ .../range_size_hash_equal.pass.cpp | 62 ++++ .../range_size_hash_equal_allocator.pass.cpp | 63 +++++ .../unord.multimap.cnstr/size.fail.cpp | 22 ++ .../unord.multimap.cnstr/size.pass.cpp | 22 ++ .../unord.multimap.cnstr/size_hash.pass.cpp | 24 ++ .../size_hash_equal.pass.cpp | 25 ++ .../size_hash_equal_allocator.pass.cpp | 26 ++ .../unord.multimap.modifiers/clear.pass.cpp | 21 ++ .../unord.multimap.modifiers/emplace.pass.cpp | 24 ++ .../emplace_hint.pass.cpp | 33 +++ .../erase_const_iter.pass.cpp | 49 ++++ .../erase_key.pass.cpp | 166 +++++++++++ .../erase_range.pass.cpp | 80 ++++++ .../insert_const_lvalue.pass.cpp | 30 ++ .../insert_hint_const_lvalue.pass.cpp | 31 ++ .../insert_hint_rvalue.pass.cpp | 59 ++++ .../insert_init.pass.cpp | 49 ++++ .../insert_range.pass.cpp | 49 ++++ .../insert_rvalue.pass.cpp | 57 ++++ .../swap_non_member.pass.cpp | 187 +++++++++++++ .../unord/unord.multiset/bucket.pass.cpp | 23 ++ .../unord.multiset/bucket_count.pass.cpp | 31 ++ .../unord/unord.multiset/bucket_size.pass.cpp | 27 ++ .../unord/unord.multiset/clear.pass.cpp | 21 ++ .../unord/unord.multiset/count.pass.cpp | 26 ++ .../unord/unord.multiset/emplace.pass.cpp | 20 ++ .../unord.multiset/emplace_hint.pass.cpp | 21 ++ .../unord/unord.multiset/eq.pass.cpp | 80 ++++++ .../unord.multiset/equal_range_const.pass.cpp | 36 +++ .../equal_range_non_const.pass.cpp | 36 +++ .../unord.multiset/erase_const_iter.pass.cpp | 26 ++ .../unord/unord.multiset/erase_key.pass.cpp | 61 ++++ .../unord/unord.multiset/erase_range.pass.cpp | 38 +++ .../unord/unord.multiset/find_const.pass.cpp | 25 ++ .../unord.multiset/find_non_const.pass.cpp | 25 ++ .../insert_const_lvalue.pass.cpp | 26 ++ .../insert_hint_const_lvalue.pass.cpp | 27 ++ .../insert_hint_rvalue.pass.cpp | 51 ++++ .../unord/unord.multiset/insert_init.pass.cpp | 24 ++ .../unord.multiset/insert_range.pass.cpp | 24 ++ .../unord.multiset/insert_rvalue.pass.cpp | 49 ++++ .../unord/unord.multiset/iterators.pass.cpp | 44 +++ .../unord/unord.multiset/load_factor.pass.cpp | 29 ++ .../unord.multiset/local_iterators.pass.cpp | 240 ++++++++++++++++ .../unord.multiset/max_bucket_count.pass.cpp | 10 + .../unord.multiset/max_load_factor.pass.cpp | 20 ++ .../unord/unord.multiset/max_size.pass.cpp | 9 + .../unord/unord.multiset/rehash.pass.cpp | 34 ++- .../unord/unord.multiset/reserve.pass.cpp | 34 ++- .../unord/unord.multiset/swap_member.pass.cpp | 183 ++++++++++++ .../unord/unord.multiset/types.pass.cpp | 19 ++ .../unord.multiset.cnstr/allocator.pass.cpp | 20 ++ .../unord.multiset.cnstr/assign_copy.pass.cpp | 56 ++++ .../unord.multiset.cnstr/assign_init.pass.cpp | 35 +++ .../unord.multiset.cnstr/assign_move.pass.cpp | 101 +++++++ .../unord.multiset.cnstr/copy.pass.cpp | 49 ++++ .../unord.multiset.cnstr/copy_alloc.pass.cpp | 49 ++++ .../unord.multiset.cnstr/default.pass.cpp | 20 ++ .../unord.multiset.cnstr/init.pass.cpp | 33 +++ .../unord.multiset.cnstr/init_size.pass.cpp | 35 +++ .../init_size_hash.pass.cpp | 36 +++ .../init_size_hash_equal.pass.cpp | 37 +++ .../init_size_hash_equal_allocator.pass.cpp | 38 +++ .../unord.multiset.cnstr/move.pass.cpp | 78 ++++++ .../unord.multiset.cnstr/move_alloc.pass.cpp | 93 ++++++ .../unord.multiset.cnstr/range.pass.cpp | 35 +++ .../unord.multiset.cnstr/range_size.pass.cpp | 37 +++ .../range_size_hash.pass.cpp | 38 +++ .../range_size_hash_equal.pass.cpp | 39 +++ .../range_size_hash_equal_allocator.pass.cpp | 40 +++ .../unord.multiset.cnstr/size.fail.cpp | 20 ++ .../unord.multiset.cnstr/size.pass.cpp | 20 ++ .../unord.multiset.cnstr/size_hash.pass.cpp | 22 ++ .../size_hash_equal.pass.cpp | 23 ++ .../size_hash_equal_allocator.pass.cpp | 24 ++ .../swap_non_member.pass.cpp | 183 ++++++++++++ .../unord/unord.set/bucket.pass.cpp | 22 ++ .../unord/unord.set/bucket_count.pass.cpp | 29 ++ .../unord/unord.set/bucket_size.pass.cpp | 24 ++ .../containers/unord/unord.set/clear.pass.cpp | 20 ++ .../containers/unord/unord.set/count.pass.cpp | 25 ++ .../unord/unord.set/emplace.pass.cpp | 23 ++ .../unord/unord.set/emplace_hint.pass.cpp | 21 ++ test/containers/unord/unord.set/eq.pass.cpp | 68 +++++ .../unord.set/equal_range_const.pass.cpp | 31 ++ .../unord.set/equal_range_non_const.pass.cpp | 31 ++ .../unord/unord.set/erase_const_iter.pass.cpp | 24 ++ .../unord/unord.set/erase_key.pass.cpp | 60 ++++ .../unord/unord.set/erase_range.pass.cpp | 37 +++ .../unord/unord.set/find_const.pass.cpp | 24 ++ .../unord/unord.set/find_non_const.pass.cpp | 24 ++ .../unord.set/insert_const_lvalue.pass.cpp | 30 ++ .../insert_hint_const_lvalue.pass.cpp | 27 ++ .../unord.set/insert_hint_rvalue.pass.cpp | 51 ++++ .../unord/unord.set/insert_init.pass.cpp | 24 ++ .../unord/unord.set/insert_range.pass.cpp | 24 ++ .../unord/unord.set/insert_rvalue.pass.cpp | 57 ++++ .../unord/unord.set/iterators.pass.cpp | 44 +++ .../unord/unord.set/load_factor.pass.cpp | 29 ++ .../unord/unord.set/local_iterators.pass.cpp | 184 ++++++++++++ .../unord/unord.set/max_bucket_count.pass.cpp | 10 + .../unord/unord.set/max_load_factor.pass.cpp | 20 ++ .../unord/unord.set/max_size.pass.cpp | 9 + .../unord/unord.set/rehash.pass.cpp | 34 ++- .../unord/unord.set/reserve.pass.cpp | 34 ++- .../unord/unord.set/swap_member.pass.cpp | 183 ++++++++++++ .../containers/unord/unord.set/types.pass.cpp | 19 ++ .../unord.set.cnstr/allocator.pass.cpp | 20 ++ .../unord.set.cnstr/assign_copy.pass.cpp | 48 ++++ .../unord.set.cnstr/assign_init.pass.cpp | 35 +++ .../unord.set.cnstr/assign_move.pass.cpp | 48 ++++ .../unord.set/unord.set.cnstr/copy.pass.cpp | 41 +++ .../unord.set.cnstr/copy_alloc.pass.cpp | 41 +++ .../unord.set.cnstr/default.pass.cpp | 20 ++ .../unord.set/unord.set.cnstr/init.pass.cpp | 33 +++ .../unord.set.cnstr/init_size.pass.cpp | 35 +++ .../unord.set.cnstr/init_size_hash.pass.cpp | 36 +++ .../init_size_hash_equal.pass.cpp | 37 +++ .../init_size_hash_equal_allocator.pass.cpp | 38 +++ .../unord.set/unord.set.cnstr/move.pass.cpp | 78 ++++++ .../unord.set.cnstr/move_alloc.pass.cpp | 44 +++ .../unord.set/unord.set.cnstr/range.pass.cpp | 35 +++ .../unord.set.cnstr/range_size.pass.cpp | 37 +++ .../unord.set.cnstr/range_size_hash.pass.cpp | 38 +++ .../range_size_hash_equal.pass.cpp | 39 +++ .../range_size_hash_equal_allocator.pass.cpp | 40 +++ .../unord.set/unord.set.cnstr/size.pass.cpp | 20 ++ .../unord.set.cnstr/size_hash.pass.cpp | 22 ++ .../unord.set.cnstr/size_hash_equal.pass.cpp | 23 ++ .../size_hash_equal_allocator.pass.cpp | 26 +- .../unord.set.swap/swap_non_member.pass.cpp | 183 ++++++++++++ test/testit | 2 +- 228 files changed, 10378 insertions(+), 58 deletions(-) diff --git a/include/__hash_table b/include/__hash_table index 6f6050d3..2b282d33 100644 --- a/include/__hash_table +++ b/include/__hash_table @@ -33,7 +33,6 @@ template struct __hash_node_base { typedef __hash_node_base __first_node; - // typedef _NodePtr pointer; _NodePtr __next_; @@ -111,7 +110,7 @@ public: _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __node_->__value_;} _LIBCPP_INLINE_VISIBILITY - pointer operator->() const {return _VSTD::addressof(__node_->__value_);} + pointer operator->() const {return pointer_traits::pointer_to(__node_->__value_);} _LIBCPP_INLINE_VISIBILITY __hash_iterator& operator++() @@ -189,7 +188,7 @@ public: _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __node_->__value_;} _LIBCPP_INLINE_VISIBILITY - pointer operator->() const {return _VSTD::addressof(__node_->__value_);} + pointer operator->() const {return pointer_traits::pointer_to(__node_->__value_);} _LIBCPP_INLINE_VISIBILITY __hash_const_iterator& operator++() @@ -255,7 +254,7 @@ public: _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __node_->__value_;} _LIBCPP_INLINE_VISIBILITY - pointer operator->() const {return &__node_->__value_;} + pointer operator->() const {return pointer_traits::pointer_to(__node_->__value_);} _LIBCPP_INLINE_VISIBILITY __hash_local_iterator& operator++() @@ -345,7 +344,7 @@ public: _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __node_->__value_;} _LIBCPP_INLINE_VISIBILITY - pointer operator->() const {return &__node_->__value_;} + pointer operator->() const {return pointer_traits::pointer_to(__node_->__value_);} _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator& operator++() @@ -505,8 +504,15 @@ public: __node_allocator; typedef allocator_traits<__node_allocator> __node_traits; typedef typename __node_traits::pointer __node_pointer; - typedef typename __node_traits::const_pointer __node_const_pointer; + typedef typename __node_traits::pointer __node_const_pointer; typedef __hash_node_base<__node_pointer> __first_node; + typedef typename pointer_traits<__node_pointer>::template +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + rebind<__first_node> +#else + rebind<__first_node>::other +#endif + __node_base_pointer; private: @@ -558,9 +564,9 @@ public: public: typedef __hash_iterator<__node_pointer> iterator; - typedef __hash_const_iterator<__node_const_pointer> const_iterator; + typedef __hash_const_iterator<__node_pointer> const_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_pointer> const_local_iterator; __hash_table() _NOEXCEPT_( @@ -706,7 +712,7 @@ public: _LIBCPP_INLINE_VISIBILITY size_type max_bucket_count() const _NOEXCEPT - {return __bucket_list_.get_deleter().__alloc().max_size();} + {return __pointer_alloc_traits::max_size(__bucket_list_.get_deleter().__alloc());} size_type bucket_size(size_type __n) const; _LIBCPP_INLINE_VISIBILITY float load_factor() const _NOEXCEPT { @@ -807,6 +813,9 @@ private: void __deallocate(__node_pointer __np) _NOEXCEPT; __node_pointer __detach() _NOEXCEPT; + + template friend class _LIBCPP_TYPE_VIS unordered_map; + template friend class _LIBCPP_TYPE_VIS unordered_multimap; }; template @@ -893,7 +902,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) if (size() > 0) { __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] = - static_cast<__node_pointer>(_VSTD::addressof(__p1_.first())); + static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())); __u.__p1_.first().__next_ = nullptr; __u.size() = 0; } @@ -917,7 +926,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u, __p1_.first().__next_ = __u.__p1_.first().__next_; __u.__p1_.first().__next_ = nullptr; __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] = - static_cast<__node_pointer>(_VSTD::addressof(__p1_.first())); + static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())); size() = __u.size(); __u.size() = 0; } @@ -1014,7 +1023,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( if (size() > 0) { __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] = - static_cast<__node_pointer>(_VSTD::addressof(__p1_.first())); + static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())); __u.__p1_.first().__next_ = nullptr; __u.size() = 0; } @@ -1236,7 +1245,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __ __node_pointer __pn = __bucket_list_[__chash]; if (__pn == nullptr) { - __pn = static_cast<__node_pointer>(_VSTD::addressof(__p1_.first())); + __pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())); __nd->__next_ = __pn->__next_; __pn->__next_ = __nd; // fix up __bucket_list_ @@ -1274,7 +1283,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __c __node_pointer __pn = __bucket_list_[__chash]; if (__pn == nullptr) { - __pn = static_cast<__node_pointer>(_VSTD::addressof(__p1_.first())); + __pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())); __cp->__next_ = __pn->__next_; __pn->__next_ = __cp; // fix up __bucket_list_ @@ -1322,7 +1331,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( { if (__p != end() && key_eq()(*__p, __cp->__value_)) { - __node_pointer __np = const_cast<__node_pointer>(__p.__node_); + __node_pointer __np = __p.__node_; __cp->__hash_ = __np->__hash_; size_type __bc = bucket_count(); if (size()+1 > __bc * max_load_factor() || __bc == 0) @@ -1380,7 +1389,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(const value_type& __x) __node_pointer __pn = __bucket_list_[__chash]; if (__pn == nullptr) { - __pn = static_cast<__node_pointer>(_VSTD::addressof(__p1_.first())); + __pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())); __h->__next_ = __pn->__next_; __pn->__next_ = __h.get(); // fix up __bucket_list_ @@ -1542,7 +1551,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc) { for (size_type __i = 0; __i < __nbc; ++__i) __bucket_list_[__i] = nullptr; - __node_pointer __pp(static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()))); + __node_pointer __pp(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()))); __node_pointer __cp = __pp->__next_; if (__cp != nullptr) { @@ -1700,7 +1709,7 @@ template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p) { - __node_pointer __np = const_cast<__node_pointer>(__p.__node_); + __node_pointer __np = __p.__node_; iterator __r(__np); ++__r; remove(__p); @@ -1717,7 +1726,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first, ++__first; erase(__p); } - __node_pointer __np = const_cast<__node_pointer>(__last.__node_); + __node_pointer __np = __last.__node_; return iterator (__np); } @@ -1757,7 +1766,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT { // current node - __node_pointer __cn = const_cast<__node_pointer>(__p.__node_); + __node_pointer __cn = __p.__node_; size_type __bc = bucket_count(); size_t __chash = __constrain_hash(__cn->__hash_, __bc); // find previous node @@ -1767,7 +1776,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT // Fix up __bucket_list_ // if __pn is not in same bucket (before begin is not in same bucket) && // if __cn->__next_ is not in same bucket (nullptr is not in same bucket) - if (__pn == _VSTD::addressof(__p1_.first()) || __constrain_hash(__pn->__hash_, __bc) != __chash) + if (__pn == static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())) + || __constrain_hash(__pn->__hash_, __bc) != __chash) { if (__cn->__next_ == nullptr || __constrain_hash(__cn->__next_->__hash_, __bc) != __chash) __bucket_list_[__chash] = nullptr; @@ -1907,10 +1917,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) __p3_.swap(__u.__p3_); if (size() > 0) __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] = - static_cast<__node_pointer>(_VSTD::addressof(__p1_.first())); + static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())); if (__u.size() > 0) __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash_, __u.bucket_count())] = - static_cast<__node_pointer>(_VSTD::addressof(__u.__p1_.first())); + static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__u.__p1_.first())); } template diff --git a/include/unordered_map b/include/unordered_map index 235b2eab..772c44b6 100644 --- a/include/unordered_map +++ b/include/unordered_map @@ -492,8 +492,8 @@ class __hash_map_node_destructor public: typedef typename __alloc_traits::pointer pointer; private: - typedef typename value_type::first_type first_type; - typedef typename value_type::second_type second_type; + typedef typename value_type::value_type::first_type first_type; + typedef typename value_type::value_type::second_type second_type; allocator_type& __na_; @@ -535,9 +535,9 @@ public: void operator()(pointer __p) _NOEXCEPT { if (__second_constructed) - __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.second)); + __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second)); if (__first_constructed) - __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.first)); + __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first)); if (__p) __alloc_traits::deallocate(__na_, __p, 1); } @@ -549,8 +549,8 @@ class _LIBCPP_TYPE_VIS __hash_map_iterator _HashIterator __i_; typedef pointer_traits __pointer_traits; - typedef const typename _HashIterator::value_type::first_type key_type; - typedef typename _HashIterator::value_type::second_type mapped_type; + typedef const typename _HashIterator::value_type::value_type::first_type key_type; + typedef typename _HashIterator::value_type::value_type::second_type mapped_type; public: typedef forward_iterator_tag iterator_category; typedef pair value_type; @@ -571,9 +571,9 @@ public: __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {} _LIBCPP_INLINE_VISIBILITY - reference operator*() const {return *operator->();} + reference operator*() const {return __i_->__cc;} _LIBCPP_INLINE_VISIBILITY - pointer operator->() const {return (pointer)__i_.operator->();} + pointer operator->() const {return pointer_traits::pointer_to(__i_->__cc);} _LIBCPP_INLINE_VISIBILITY __hash_map_iterator& operator++() {++__i_; return *this;} @@ -605,8 +605,8 @@ class _LIBCPP_TYPE_VIS __hash_map_const_iterator _HashIterator __i_; typedef pointer_traits __pointer_traits; - typedef const typename _HashIterator::value_type::first_type key_type; - typedef typename _HashIterator::value_type::second_type mapped_type; + typedef const typename _HashIterator::value_type::value_type::first_type key_type; + typedef typename _HashIterator::value_type::value_type::second_type mapped_type; public: typedef forward_iterator_tag iterator_category; typedef pair value_type; @@ -632,9 +632,9 @@ public: : __i_(__i.__i_) {} _LIBCPP_INLINE_VISIBILITY - reference operator*() const {return *operator->();} + reference operator*() const {return __i_->__cc;} _LIBCPP_INLINE_VISIBILITY - pointer operator->() const {return (pointer)__i_.operator->();} + pointer operator->() const {return pointer_traits::pointer_to(__i_->__cc);} _LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator& operator++() {++__i_; return *this;} @@ -671,11 +671,58 @@ public: typedef _Pred key_equal; typedef _Alloc allocator_type; typedef pair value_type; + typedef pair __nc_value_type; typedef value_type& reference; typedef const value_type& const_reference; private: - typedef pair __value_type; +#if __cplusplus >= 201103L + union __value_type + { + typedef typename unordered_map::value_type value_type; + typedef typename unordered_map::__nc_value_type __nc_value_type; + value_type __cc; + __nc_value_type __nc; + + template + __value_type(_Args&& ...__args) + : __cc(std::forward<_Args>(__args)...) {} + + __value_type(const __value_type& __v) + : __cc(std::move(__v.__cc)) {} + + __value_type(__value_type&& __v) + : __nc(std::move(__v.__nc)) {} + + __value_type& operator=(const __value_type& __v) + {__nc = __v.__cc; return *this;} + + __value_type& operator=(__value_type&& __v) + {__nc = std::move(__v.__nc); return *this;} + + ~__value_type() {__cc.~value_type();} + + operator const value_type& () const {return __cc;} + }; +#else + struct __value_type + { + typedef typename unordered_map::value_type value_type; + value_type __cc; + + __value_type() {} + + template + __value_type(const _A0& __a0) + : __cc(__a0) {} + + template + __value_type(const _A0& __a0, const _A1& __a1) + : __cc(__a0, __a1) {} + + operator const value_type& () const {return __cc;} + }; +#endif typedef __unordered_map_hasher __hasher; typedef __unordered_map_equal __key_equal; typedef typename allocator_traits::template @@ -750,7 +797,16 @@ public: _LIBCPP_INLINE_VISIBILITY unordered_map& operator=(const unordered_map& __u) { +#if __cplusplus >= 201103L __table_ = __u.__table_; +#else + __table_.clear(); + __table_.hash_function() = __u.__table_.hash_function(); + __table_.key_eq() = __u.__table_.key_eq(); + __table_.max_load_factor() = __u.__table_.max_load_factor(); + __table_.__copy_assign_alloc(__u.__table_); + insert(__u.begin(), __u.end()); +#endif return *this; } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1132,10 +1188,10 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0) { __node_allocator& __na = __table_.__node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), + __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::forward<_A0>(__a0)); __h.get_deleter().__first_constructed = true; - __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second)); + __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; return __h; } @@ -1180,9 +1236,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& { __node_allocator& __na = __table_.__node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), __k); + __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), __k); __h.get_deleter().__first_constructed = true; - __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second)); + __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; return _VSTD::move(__h); } @@ -1304,11 +1360,58 @@ public: typedef _Pred key_equal; typedef _Alloc allocator_type; typedef pair value_type; + typedef pair __nc_value_type; typedef value_type& reference; typedef const value_type& const_reference; private: - typedef pair __value_type; +#if __cplusplus >= 201103L + union __value_type + { + typedef typename unordered_multimap::value_type value_type; + typedef typename unordered_multimap::__nc_value_type __nc_value_type; + value_type __cc; + __nc_value_type __nc; + + template + __value_type(_Args&& ...__args) + : __cc(std::forward<_Args>(__args)...) {} + + __value_type(const __value_type& __v) + : __cc(std::move(__v.__cc)) {} + + __value_type(__value_type&& __v) + : __nc(std::move(__v.__nc)) {} + + __value_type& operator=(const __value_type& __v) + {__nc = __v.__cc; return *this;} + + __value_type& operator=(__value_type&& __v) + {__nc = std::move(__v.__nc); return *this;} + + ~__value_type() {__cc.~value_type();} + + operator const value_type& () const {return __cc;} + }; +#else + struct __value_type + { + typedef typename unordered_multimap::value_type value_type; + value_type __cc; + + __value_type() {} + + template + __value_type(const _A0& __a0) + : __cc(__a0) {} + + template + __value_type(const _A0& __a0, const _A1& __a1) + : __cc(__a0, __a1) {} + + operator const value_type& () const {return __cc;} + }; +#endif typedef __unordered_map_hasher __hasher; typedef __unordered_map_equal __key_equal; typedef typename allocator_traits::template @@ -1382,7 +1485,16 @@ public: _LIBCPP_INLINE_VISIBILITY unordered_multimap& operator=(const unordered_multimap& __u) { +#if __cplusplus >= 201103L __table_ = __u.__table_; +#else + __table_.clear(); + __table_.hash_function() = __u.__table_.hash_function(); + __table_.key_eq() = __u.__table_.key_eq(); + __table_.max_load_factor() = __u.__table_.max_load_factor(); + __table_.__copy_assign_alloc(__u.__table_); + insert(__u.begin(), __u.end()); +#endif return *this; } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1754,10 +1866,10 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0 { __node_allocator& __na = __table_.__node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), + __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::forward<_A0>(__a0)); __h.get_deleter().__first_constructed = true; - __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second)); + __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; return __h; } diff --git a/lib/buildit b/lib/buildit index 1f77dbb6..e84618d4 100755 --- a/lib/buildit +++ b/lib/buildit @@ -35,7 +35,7 @@ then RC_ProjectSourceVersion=1 fi -EXTRA_FLAGS="-std=c++0x -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion \ +EXTRA_FLAGS="-std=c++11 -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion \ -Wnewline-eof -Wpadded -Wmissing-prototypes -Wstrict-aliasing=2 \ -Wstrict-overflow=4 " @@ -48,7 +48,7 @@ case $TRIPLE in SOEXT=dylib if [ "$MACOSX_DEPLOYMENT_TARGET" == "10.6" ] then - EXTRA_FLAGS="-std=c++0x -U__STRICT_ANSI__" + EXTRA_FLAGS="-std=c++11 -U__STRICT_ANSI__" LDSHARED_FLAGS="-o libc++.1.dylib \ -dynamiclib -nodefaultlibs -current_version 1 \ -compatibility_version 1 \ diff --git a/test/containers/unord/unord.map/bucket.pass.cpp b/test/containers/unord/unord.map/bucket.pass.cpp index 6cb6fbb0..f7ff18ec 100644 --- a/test/containers/unord/unord.map/bucket.pass.cpp +++ b/test/containers/unord/unord.map/bucket.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -39,4 +41,25 @@ int main() for (size_t i = 0; i < 13; ++i) assert(c.bucket(i) == i % bc); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + const C c(std::begin(a), std::end(a)); + size_t bc = c.bucket_count(); + assert(bc >= 5); + for (size_t i = 0; i < 13; ++i) + assert(c.bucket(i) == i % bc); + } +#endif } diff --git a/test/containers/unord/unord.map/bucket_count.pass.cpp b/test/containers/unord/unord.map/bucket_count.pass.cpp index 478f9ade..dbc24eed 100644 --- a/test/containers/unord/unord.map/bucket_count.pass.cpp +++ b/test/containers/unord/unord.map/bucket_count.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -46,4 +48,33 @@ int main() const C c(std::begin(a), std::end(a)); assert(c.bucket_count() >= 11); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef C::const_iterator I; + typedef std::pair P; + const C c; + assert(c.bucket_count() == 0); + } + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef C::const_iterator I; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + const C c(std::begin(a), std::end(a)); + assert(c.bucket_count() >= 11); + } +#endif } diff --git a/test/containers/unord/unord.map/bucket_size.pass.cpp b/test/containers/unord/unord.map/bucket_size.pass.cpp index ab1f6849..967bb8d9 100644 --- a/test/containers/unord/unord.map/bucket_size.pass.cpp +++ b/test/containers/unord/unord.map/bucket_size.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -41,4 +43,27 @@ int main() assert(c.bucket_size(3) == 1); assert(c.bucket_size(4) == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + const C c(std::begin(a), std::end(a)); + assert(c.bucket_count() >= 5); + assert(c.bucket_size(0) == 0); + assert(c.bucket_size(1) == 1); + assert(c.bucket_size(2) == 1); + assert(c.bucket_size(3) == 1); + assert(c.bucket_size(4) == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/count.pass.cpp b/test/containers/unord/unord.map/count.pass.cpp index fa40d0a1..04d16991 100644 --- a/test/containers/unord/unord.map/count.pass.cpp +++ b/test/containers/unord/unord.map/count.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -39,4 +41,25 @@ int main() assert(c.count(30) == 1); assert(c.count(5) == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + const C c(std::begin(a), std::end(a)); + assert(c.count(30) == 1); + assert(c.count(5) == 0); + } +#endif } diff --git a/test/containers/unord/unord.map/eq.pass.cpp b/test/containers/unord/unord.map/eq.pass.cpp index 8e7ed99b..ec137857 100644 --- a/test/containers/unord/unord.map/eq.pass.cpp +++ b/test/containers/unord/unord.map/eq.pass.cpp @@ -23,6 +23,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -89,4 +91,73 @@ int main() assert( (c1 == c2)); assert(!(c1 != c2)); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + const C c1(std::begin(a), std::end(a)); + const C c2; + assert(!(c1 == c2)); + assert( (c1 != c2)); + } + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + const C c1(std::begin(a), std::end(a)); + const C c2 = c1; + assert( (c1 == c2)); + assert(!(c1 != c2)); + } + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + C c1(std::begin(a), std::end(a)); + C c2 = c1; + c2.rehash(30); + assert( (c1 == c2)); + assert(!(c1 != c2)); + c2.insert(P(90, "ninety")); + assert(!(c1 == c2)); + assert( (c1 != c2)); + c1.insert(P(90, "ninety")); + assert( (c1 == c2)); + assert(!(c1 != c2)); + } +#endif } diff --git a/test/containers/unord/unord.map/equal_range_const.pass.cpp b/test/containers/unord/unord.map/equal_range_const.pass.cpp index 766d740a..8f9c58e4 100644 --- a/test/containers/unord/unord.map/equal_range_const.pass.cpp +++ b/test/containers/unord/unord.map/equal_range_const.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -44,4 +46,30 @@ int main() r = c.equal_range(5); assert(std::distance(r.first, r.second) == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef C::const_iterator I; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + const C c(std::begin(a), std::end(a)); + std::pair r = c.equal_range(30); + assert(std::distance(r.first, r.second) == 1); + assert(r.first->first == 30); + assert(r.first->second == "thirty"); + r = c.equal_range(5); + assert(std::distance(r.first, r.second) == 0); + } +#endif } diff --git a/test/containers/unord/unord.map/equal_range_non_const.pass.cpp b/test/containers/unord/unord.map/equal_range_non_const.pass.cpp index ddc930fb..9291eb4f 100644 --- a/test/containers/unord/unord.map/equal_range_non_const.pass.cpp +++ b/test/containers/unord/unord.map/equal_range_non_const.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -44,4 +46,30 @@ int main() r = c.equal_range(5); assert(std::distance(r.first, r.second) == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef C::iterator I; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + C c(std::begin(a), std::end(a)); + std::pair r = c.equal_range(30); + assert(std::distance(r.first, r.second) == 1); + assert(r.first->first == 30); + assert(r.first->second == "thirty"); + r = c.equal_range(5); + assert(std::distance(r.first, r.second) == 0); + } +#endif } diff --git a/test/containers/unord/unord.map/find_const.pass.cpp b/test/containers/unord/unord.map/find_const.pass.cpp index 5d4eefb8..c049d239 100644 --- a/test/containers/unord/unord.map/find_const.pass.cpp +++ b/test/containers/unord/unord.map/find_const.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -42,4 +44,28 @@ int main() i = c.find(5); assert(i == c.cend()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + const C c(std::begin(a), std::end(a)); + C::const_iterator i = c.find(30); + assert(i->first == 30); + assert(i->second == "thirty"); + i = c.find(5); + assert(i == c.cend()); + } +#endif } diff --git a/test/containers/unord/unord.map/find_non_const.pass.cpp b/test/containers/unord/unord.map/find_non_const.pass.cpp index c6ebe63b..04126938 100644 --- a/test/containers/unord/unord.map/find_non_const.pass.cpp +++ b/test/containers/unord/unord.map/find_non_const.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -42,4 +44,28 @@ int main() i = c.find(5); assert(i == c.end()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + C c(std::begin(a), std::end(a)); + C::iterator i = c.find(30); + assert(i->first == 30); + assert(i->second == "thirty"); + i = c.find(5); + assert(i == c.end()); + } +#endif } diff --git a/test/containers/unord/unord.map/iterators.pass.cpp b/test/containers/unord/unord.map/iterators.pass.cpp index c8a52660..7d99fdf9 100644 --- a/test/containers/unord/unord.map/iterators.pass.cpp +++ b/test/containers/unord/unord.map/iterators.pass.cpp @@ -24,6 +24,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -64,4 +66,46 @@ int main() assert(std::distance(c.cbegin(), c.cend()) == c.size()); C::const_iterator i; } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 5); + assert(c.size() == 4); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + C::iterator i; + } + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + const C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 5); + assert(c.size() == 4); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + C::const_iterator i; + } +#endif } diff --git a/test/containers/unord/unord.map/load_factor.pass.cpp b/test/containers/unord/unord.map/load_factor.pass.cpp index fcb2b9b3..70e6048c 100644 --- a/test/containers/unord/unord.map/load_factor.pass.cpp +++ b/test/containers/unord/unord.map/load_factor.pass.cpp @@ -20,6 +20,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -45,4 +47,31 @@ int main() const C c; assert(c.load_factor() == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + const C c(std::begin(a), std::end(a)); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + } + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + const C c; + assert(c.load_factor() == 0); + } +#endif } diff --git a/test/containers/unord/unord.map/local_iterators.pass.cpp b/test/containers/unord/unord.map/local_iterators.pass.cpp index c9812d04..ec10f50b 100644 --- a/test/containers/unord/unord.map/local_iterators.pass.cpp +++ b/test/containers/unord/unord.map/local_iterators.pass.cpp @@ -24,6 +24,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -218,4 +220,202 @@ int main() assert(i->first == 4); assert(i->second == "four"); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + typedef C::local_iterator I; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 5); + C::size_type b = c.bucket(0); + I i = c.begin(b); + I j = c.end(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(i->first == 1); + assert(i->second == "one"); + + b = c.bucket(2); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(i->first == 2); + assert(i->second == "two"); + + b = c.bucket(3); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(i->first == 3); + assert(i->second == "three"); + + b = c.bucket(4); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(i->first == 4); + assert(i->second == "four"); + } + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + typedef C::const_local_iterator I; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + const C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 5); + C::size_type b = c.bucket(0); + I i = c.begin(b); + I j = c.end(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(i->first == 1); + assert(i->second == "one"); + + b = c.bucket(2); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(i->first == 2); + assert(i->second == "two"); + + b = c.bucket(3); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(i->first == 3); + assert(i->second == "three"); + + b = c.bucket(4); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(i->first == 4); + assert(i->second == "four"); + } + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + typedef C::const_local_iterator I; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 5); + C::size_type b = c.bucket(0); + I i = c.cbegin(b); + I j = c.cend(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(i->first == 1); + assert(i->second == "one"); + + b = c.bucket(2); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(i->first == 2); + assert(i->second == "two"); + + b = c.bucket(3); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(i->first == 3); + assert(i->second == "three"); + + b = c.bucket(4); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(i->first == 4); + assert(i->second == "four"); + } + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + typedef C::const_local_iterator I; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + const C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 5); + C::size_type b = c.bucket(0); + I i = c.cbegin(b); + I j = c.cend(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(i->first == 1); + assert(i->second == "one"); + + b = c.bucket(2); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(i->first == 2); + assert(i->second == "two"); + + b = c.bucket(3); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(i->first == 3); + assert(i->second == "three"); + + b = c.bucket(4); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(i->first == 4); + assert(i->second == "four"); + } +#endif } diff --git a/test/containers/unord/unord.map/max_bucket_count.pass.cpp b/test/containers/unord/unord.map/max_bucket_count.pass.cpp index 2a89f5c0..a1f1c3c3 100644 --- a/test/containers/unord/unord.map/max_bucket_count.pass.cpp +++ b/test/containers/unord/unord.map/max_bucket_count.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -28,4 +30,14 @@ int main() const C c; assert(c.max_bucket_count() > 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef C::const_iterator I; + typedef std::pair P; + const C c; + assert(c.max_bucket_count() > 0); + } +#endif } diff --git a/test/containers/unord/unord.map/max_load_factor.pass.cpp b/test/containers/unord/unord.map/max_load_factor.pass.cpp index 57b64b29..a644e7bf 100644 --- a/test/containers/unord/unord.map/max_load_factor.pass.cpp +++ b/test/containers/unord/unord.map/max_load_factor.pass.cpp @@ -20,6 +20,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -36,4 +38,22 @@ int main() c.max_load_factor(2.5); assert(c.max_load_factor() == 2.5); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + const C c; + assert(c.max_load_factor() == 1); + } + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + C c; + assert(c.max_load_factor() == 1); + c.max_load_factor(2.5); + assert(c.max_load_factor() == 2.5); + } +#endif } diff --git a/test/containers/unord/unord.map/max_size.pass.cpp b/test/containers/unord/unord.map/max_size.pass.cpp index bde1e2da..1993741d 100644 --- a/test/containers/unord/unord.map/max_size.pass.cpp +++ b/test/containers/unord/unord.map/max_size.pass.cpp @@ -18,10 +18,19 @@ #include #include +#include "../../min_allocator.h" + int main() { { std::unordered_map u; assert(u.max_size() > 0); } +#if __cplusplus >= 201103L + { + std::unordered_map, std::equal_to, + min_allocator>> u; + assert(u.max_size() > 0); + } +#endif } diff --git a/test/containers/unord/unord.map/rehash.pass.cpp b/test/containers/unord/unord.map/rehash.pass.cpp index 61cd4f57..c516872c 100644 --- a/test/containers/unord/unord.map/rehash.pass.cpp +++ b/test/containers/unord/unord.map/rehash.pass.cpp @@ -19,7 +19,10 @@ #include #include -void test(const std::unordered_map& c) +#include "../../min_allocator.h" + +template +void test(const C& c) { assert(c.size() == 4); assert(c.at(1) == "one"); @@ -56,4 +59,33 @@ int main() assert(c.bucket_count() == 31); test(c); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + test(c); + assert(c.bucket_count() >= 5); + c.rehash(3); + assert(c.bucket_count() == 5); + test(c); + c.max_load_factor(2); + c.rehash(3); + assert(c.bucket_count() == 3); + test(c); + c.rehash(31); + assert(c.bucket_count() == 31); + test(c); + } +#endif } diff --git a/test/containers/unord/unord.map/reserve.pass.cpp b/test/containers/unord/unord.map/reserve.pass.cpp index 9a8eb8bc..753316f7 100644 --- a/test/containers/unord/unord.map/reserve.pass.cpp +++ b/test/containers/unord/unord.map/reserve.pass.cpp @@ -19,7 +19,10 @@ #include #include -void test(const std::unordered_map& c) +#include "../../min_allocator.h" + +template +void test(const C& c) { assert(c.size() == 4); assert(c.at(1) == "one"); @@ -56,4 +59,33 @@ int main() assert(c.bucket_count() >= 16); test(c); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + test(c); + assert(c.bucket_count() >= 5); + c.reserve(3); + assert(c.bucket_count() == 5); + test(c); + c.max_load_factor(2); + c.reserve(3); + assert(c.bucket_count() >= 2); + test(c); + c.reserve(31); + assert(c.bucket_count() >= 16); + test(c); + } +#endif } diff --git a/test/containers/unord/unord.map/swap_member.pass.cpp b/test/containers/unord/unord.map/swap_member.pass.cpp index 871815b2..311a9a54 100644 --- a/test/containers/unord/unord.map/swap_member.pass.cpp +++ b/test/containers/unord/unord.map/swap_member.pass.cpp @@ -22,6 +22,7 @@ #include "../../test_compare.h" #include "../../test_hash.h" #include "../../test_allocator.h" +#include "../../min_allocator.h" int main() { @@ -386,4 +387,186 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair P; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair P; + P a2[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(c1.at(10) == "ten"); + assert(c1.at(20) == "twenty"); + assert(c1.at(30) == "thirty"); + assert(c1.at(40) == "fourty"); + assert(c1.at(50) == "fifty"); + assert(c1.at(60) == "sixty"); + assert(c1.at(70) == "seventy"); + assert(c1.at(80) == "eighty"); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair P; + P a1[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 5); + assert(c2.size() == 4); + assert(c2.at(1) == "one"); + assert(c2.at(2) == "two"); + assert(c2.at(3) == "three"); + assert(c2.at(4) == "four"); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair P; + P a1[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + P a2[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(c1.at(10) == "ten"); + assert(c1.at(20) == "twenty"); + assert(c1.at(30) == "thirty"); + assert(c1.at(40) == "fourty"); + assert(c1.at(50) == "fifty"); + assert(c1.at(60) == "sixty"); + assert(c1.at(70) == "seventy"); + assert(c1.at(80) == "eighty"); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 5); + assert(c2.size() == 4); + assert(c2.at(1) == "one"); + assert(c2.at(2) == "two"); + assert(c2.at(3) == "three"); + assert(c2.at(4) == "four"); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/types.pass.cpp b/test/containers/unord/unord.map/types.pass.cpp index da7d5696..4bf45916 100644 --- a/test/containers/unord/unord.map/types.pass.cpp +++ b/test/containers/unord/unord.map/types.pass.cpp @@ -31,6 +31,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -48,4 +50,22 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp index 7bb73552..0f9e4cef 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -44,4 +45,25 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + C c(min_allocator >{}); + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp index dda88e3b..8e8f97d9 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -116,4 +117,51 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef min_allocator > A; + typedef std::unordered_map >, + test_compare >, + A + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(3), + A() + ); + c = c0; + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == A()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp index 54e41e43..86d44f20 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" +#include "../../../min_allocator.h" int main() { @@ -58,5 +59,39 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef min_allocator > A; + typedef std::unordered_map >, + test_compare >, + A + > C; + typedef std::pair P; + C c = { + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + c = { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + assert(c.bucket_count() >= 5); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp index 826ccb47..97924edb 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -164,5 +165,53 @@ int main() assert(c.max_load_factor() == 1); assert(c0.size() == 0); } +#if __cplusplus >= 201103L + { + typedef min_allocator > A; + typedef std::unordered_map >, + test_compare >, + A + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(3), + A() + ); + c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == A()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c0.size() == 0); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp index 7bb294c8..398f2fd8 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -106,4 +107,45 @@ int main() assert(c.max_load_factor() == 1); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + C c = c0; + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp index 87dc2493..c7d5396e 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -65,4 +66,45 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + C c(c0, min_allocator >()); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp index 762d5282..b32c260e 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -44,4 +45,25 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + C c; + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp index 5b3fe7e8..be5a70fc 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -58,5 +59,38 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c = { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + assert(c.bucket_count() >= 5); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp index 4aa1ea62..fd28845f 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -60,5 +61,40 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7 + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp index d499adc2..bcc97b67 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -61,5 +62,41 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp index 25c212e6..5e218737 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp @@ -24,6 +24,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -63,5 +64,42 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp index d33efeec..0f5e7b58 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp @@ -24,6 +24,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -64,5 +65,43 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp index b094330c..5c5c53a4 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -104,5 +105,84 @@ int main() assert(c0.empty()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c0(7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 0); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + + assert(c0.empty()); + } + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + + assert(c0.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp index a1434a52..0f734808 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -109,5 +110,48 @@ int main() assert(c0.empty()); } +#if __cplusplus >= 201103L + { + typedef std::pair P; + typedef min_allocator> A; + typedef std::unordered_map >, + test_compare >, + A + > C; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + A() + ); + C c(std::move(c0), A()); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == A()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + + assert(c0.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp index 0c4ccec7..25e1d8d6 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp @@ -26,6 +26,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -62,4 +63,39 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0]))); + assert(c.bucket_count() >= 5); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp index 0d8b1a7e..42822bc6 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp @@ -26,6 +26,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -64,4 +65,41 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 10 + ); + assert(c.bucket_count() == 11); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp index 0d55b26c..f6f294fd 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp @@ -27,6 +27,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -66,4 +67,42 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp index 0c81503e..16b7f8bf 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp @@ -27,6 +27,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -67,4 +68,43 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp index c8371ce0..82825ce5 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp @@ -28,6 +28,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -69,4 +70,44 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp b/test/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp index ce19c177..71303660 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -44,4 +45,25 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + C c = 7; + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp index ab2b1866..81cb07dd 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -44,4 +45,25 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + C c(7); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp index 0d4d7a15..783189c7 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -46,4 +47,27 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + C c(7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp index 44fcc30c..9c7f2b57 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -47,4 +48,28 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + C c(7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp index be089782..139ffad1 100644 --- a/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -48,4 +49,29 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map >, + test_compare >, + min_allocator > + > C; + C c(7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.elem/at.pass.cpp b/test/containers/unord/unord.map/unord.map.elem/at.pass.cpp index 720a7c59..c8eade2f 100644 --- a/test/containers/unord/unord.map/unord.map.elem/at.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.elem/at.pass.cpp @@ -21,6 +21,7 @@ #include #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -75,4 +76,59 @@ int main() } assert(c.size() == 4); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.size() == 4); + c.at(1) = "ONE"; + assert(c.at(1) == "ONE"); + try + { + c.at(11) = "eleven"; + assert(false); + } + catch (std::out_of_range&) + { + } + assert(c.size() == 4); + } + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + const C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.size() == 4); + assert(c.at(1) == "one"); + try + { + c.at(11); + assert(false); + } + catch (std::out_of_range&) + { + } + assert(c.size() == 4); + } +#endif } diff --git a/test/containers/unord/unord.map/unord.map.elem/index.pass.cpp b/test/containers/unord/unord.map/unord.map.elem/index.pass.cpp index 071e059b..bbee80d9 100644 --- a/test/containers/unord/unord.map/unord.map.elem/index.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.elem/index.pass.cpp @@ -20,6 +20,7 @@ #include #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -65,4 +66,50 @@ int main() assert(c.at(11) == "eleven"); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.size() == 4); + c[1] = "ONE"; + assert(c.at(1) == "ONE"); + c[11] = "eleven"; + assert(c.size() == 5); + assert(c.at(11) == "eleven"); + } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.size() == 4); + c[1] = "ONE"; + assert(c.at(1) == "ONE"); + c[11] = "eleven"; + assert(c.size() == 5); + assert(c.at(11) == "eleven"); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp b/test/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp index 450fed38..224286ab 100644 --- a/test/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp +++ b/test/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -386,4 +387,186 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair P; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair P; + P a2[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(c1.at(10) == "ten"); + assert(c1.at(20) == "twenty"); + assert(c1.at(30) == "thirty"); + assert(c1.at(40) == "fourty"); + assert(c1.at(50) == "fifty"); + assert(c1.at(60) == "sixty"); + assert(c1.at(70) == "seventy"); + assert(c1.at(80) == "eighty"); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair P; + P a1[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 5); + assert(c2.size() == 4); + assert(c2.at(1) == "one"); + assert(c2.at(2) == "two"); + assert(c2.at(3) == "three"); + assert(c2.at(4) == "four"); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair P; + P a1[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + P a2[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(c1.at(10) == "ten"); + assert(c1.at(20) == "twenty"); + assert(c1.at(30) == "thirty"); + assert(c1.at(40) == "fourty"); + assert(c1.at(50) == "fifty"); + assert(c1.at(60) == "sixty"); + assert(c1.at(70) == "seventy"); + assert(c1.at(80) == "eighty"); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 5); + assert(c2.size() == 4); + assert(c2.at(1) == "one"); + assert(c2.at(2) == "two"); + assert(c2.at(3) == "three"); + assert(c2.at(4) == "four"); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp index c51e3d09..0e0f188b 100644 --- a/test/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp +++ b/test/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -37,4 +39,23 @@ int main() c.clear(); assert(c.size() == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + c.clear(); + assert(c.size() == 0); + } +#endif } diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp index 488d2ba0..515b3292 100644 --- a/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp +++ b/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp @@ -20,6 +20,7 @@ #include #include "../../../Emplaceable.h" +#include "../../../min_allocator.h" int main() { @@ -47,5 +48,31 @@ int main() assert(r.first->first == 5); assert(r.first->second == Emplaceable(6, 7)); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair R; + C c; + R r = c.emplace(3); + assert(r.second); + assert(c.size() == 1); + assert(r.first->first == 3); + assert(r.first->second == Emplaceable()); + + r = c.emplace(std::pair(4, Emplaceable(5, 6))); + assert(r.second); + assert(c.size() == 2); + assert(r.first->first == 4); + assert(r.first->second == Emplaceable(5, 6)); + + r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5), + std::forward_as_tuple(6, 7)); + assert(r.second); + assert(c.size() == 3); + assert(r.first->first == 5); + assert(r.first->second == Emplaceable(6, 7)); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp index 463fc3b5..6c2a75a2 100644 --- a/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp +++ b/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp @@ -20,6 +20,7 @@ #include #include "../../../Emplaceable.h" +#include "../../../min_allocator.h" int main() { @@ -45,5 +46,29 @@ int main() assert(r->first == 5); assert(r->second == Emplaceable(6, 7)); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + C c; + C::const_iterator e = c.end(); + R r = c.emplace_hint(e, 3); + assert(c.size() == 1); + assert(r->first == 3); + assert(r->second == Emplaceable()); + + r = c.emplace_hint(e, std::pair(4, Emplaceable(5, 6))); + assert(c.size() == 2); + assert(r->first == 4); + assert(r->second == Emplaceable(5, 6)); + + r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(5), + std::forward_as_tuple(6, 7)); + assert(c.size() == 3); + assert(r->first == 5); + assert(r->second == Emplaceable(6, 7)); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp index f7127d51..977581cd 100644 --- a/test/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp +++ b/test/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -41,4 +43,27 @@ int main() assert(c.at(3) == "three"); assert(c.at(4) == "four"); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + C::const_iterator i = c.find(2); + C::iterator j = c.erase(i); + assert(c.size() == 3); + assert(c.at(1) == "one"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + } +#endif } diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp index cc59bb90..c2a8666b 100644 --- a/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp +++ b/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -77,4 +79,63 @@ int main() assert(c.erase(3) == 0); assert(c.size() == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.erase(5) == 0); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + + assert(c.erase(2) == 1); + assert(c.size() == 3); + assert(c.at(1) == "one"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + + assert(c.erase(2) == 0); + assert(c.size() == 3); + assert(c.at(1) == "one"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + + assert(c.erase(4) == 1); + assert(c.size() == 2); + assert(c.at(1) == "one"); + assert(c.at(3) == "three"); + + assert(c.erase(4) == 0); + assert(c.size() == 2); + assert(c.at(1) == "one"); + assert(c.at(3) == "three"); + + assert(c.erase(1) == 1); + assert(c.size() == 1); + assert(c.at(3) == "three"); + + assert(c.erase(1) == 0); + assert(c.size() == 1); + assert(c.at(3) == "three"); + + assert(c.erase(3) == 1); + assert(c.size() == 0); + + assert(c.erase(3) == 0); + assert(c.size() == 0); + } +#endif } diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp index b5c43837..ad915fd6 100644 --- a/test/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp +++ b/test/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -56,4 +58,42 @@ int main() assert(c.size() == 0); assert(k == c.end()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + C::const_iterator i = c.find(2); + C::const_iterator j = next(i, 1); + C::iterator k = c.erase(i, i); + assert(k == i); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + + k = c.erase(i, j); + assert(c.size() == 3); + assert(k == j); + assert(c.at(1) == "one"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + + k = c.erase(c.cbegin(), c.cend()); + assert(k == c.cend()); + assert(c.size() == 0); + assert(k == c.end()); + } +#endif } diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp index d9ab4156..8bf66caf 100644 --- a/test/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp +++ b/test/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -49,4 +51,36 @@ int main() assert(r.first->first == 5.5); assert(r.first->second == 4); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair R; + typedef C::value_type P; + C c; + R r = c.insert(P(3.5, 3)); + assert(r.second); + assert(c.size() == 1); + assert(r.first->first == 3.5); + assert(r.first->second == 3); + + r = c.insert(P(3.5, 4)); + assert(!r.second); + assert(c.size() == 1); + assert(r.first->first == 3.5); + assert(r.first->second == 3); + + r = c.insert(P(4.5, 4)); + assert(r.second); + assert(c.size() == 2); + assert(r.first->first == 4.5); + assert(r.first->second == 4); + + r = c.insert(P(5.5, 4)); + assert(r.second); + assert(c.size() == 3); + assert(r.first->first == 5.5); + assert(r.first->second == 4); + } +#endif } diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp index 0d2ffe39..788105e7 100644 --- a/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp +++ b/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -46,4 +48,33 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef C::value_type P; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, P(3.5, 3)); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert(e, P(3.5, 4)); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert(e, P(4.5, 4)); + assert(c.size() == 2); + assert(r->first == 4.5); + assert(r->second == 4); + + r = c.insert(e, P(5.5, 4)); + assert(c.size() == 3); + assert(r->first == 5.5); + assert(r->second == 4); + } +#endif } diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp index 6fc6e8ed..3fef2701 100644 --- a/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp +++ b/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp @@ -21,6 +21,7 @@ #include #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -78,4 +79,62 @@ int main() assert(r->second == 4); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef std::pair P; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, P(3.5, 3)); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert(e, P(3.5, 4)); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert(e, P(4.5, 4)); + assert(c.size() == 2); + assert(r->first == 4.5); + assert(r->second == 4); + + r = c.insert(e, P(5.5, 4)); + assert(c.size() == 3); + assert(r->first == 5.5); + assert(r->second == 4); + } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef std::pair P; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, P(3, 3)); + assert(c.size() == 1); + assert(r->first == 3); + assert(r->second == 3); + + r = c.insert(e, P(3, 4)); + assert(c.size() == 1); + assert(r->first == 3); + assert(r->second == 3); + + r = c.insert(e, P(4, 4)); + assert(c.size() == 2); + assert(r->first == 4); + assert(r->second == 4); + + r = c.insert(e, P(5, 4)); + assert(c.size() == 3); + assert(r->first == 5); + assert(r->second == 4); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp index 532c7cb2..b667c7e4 100644 --- a/test/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp +++ b/test/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp @@ -20,6 +20,7 @@ #include #include "test_iterators.h" +#include "../../../min_allocator.h" int main() { @@ -44,5 +45,28 @@ int main() assert(c.at(3) == "three"); assert(c.at(4) == "four"); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + C c; + c.insert( + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + } + ); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp index eda189a7..68cb25c8 100644 --- a/test/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp +++ b/test/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp @@ -21,6 +21,7 @@ #include #include "test_iterators.h" +#include "../../../min_allocator.h" int main() { @@ -44,4 +45,27 @@ int main() assert(c.at(3) == "three"); assert(c.at(4) == "four"); } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c; + c.insert(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0]))); + assert(c.size() == 4); + assert(c.at(1) == "one"); + assert(c.at(2) == "two"); + assert(c.at(3) == "three"); + assert(c.at(4) == "four"); + } +#endif } diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp index 3b156ff6..3e050e94 100644 --- a/test/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp +++ b/test/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp @@ -21,6 +21,7 @@ #include #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -84,4 +85,68 @@ int main() assert(r.first->second == 4); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair R; + typedef std::pair P; + C c; + R r = c.insert(P(3.5, 3)); + assert(r.second); + assert(c.size() == 1); + assert(r.first->first == 3.5); + assert(r.first->second == 3); + + r = c.insert(P(3.5, 4)); + assert(!r.second); + assert(c.size() == 1); + assert(r.first->first == 3.5); + assert(r.first->second == 3); + + r = c.insert(P(4.5, 4)); + assert(r.second); + assert(c.size() == 2); + assert(r.first->first == 4.5); + assert(r.first->second == 4); + + r = c.insert(P(5.5, 4)); + assert(r.second); + assert(c.size() == 3); + assert(r.first->first == 5.5); + assert(r.first->second == 4); + } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair R; + typedef std::pair P; + C c; + R r = c.insert(P(3, 3)); + assert(r.second); + assert(c.size() == 1); + assert(r.first->first == 3); + assert(r.first->second == 3); + + r = c.insert(P(3, 4)); + assert(!r.second); + assert(c.size() == 1); + assert(r.first->first == 3); + assert(r.first->second == 3); + + r = c.insert(P(4, 4)); + assert(r.second); + assert(c.size() == 2); + assert(r.first->first == 4); + assert(r.first->second == 4); + + r = c.insert(P(5, 4)); + assert(r.second); + assert(c.size() == 3); + assert(r.first->first == 5); + assert(r.first->second == 4); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/containers/unord/unord.multimap/bucket.pass.cpp b/test/containers/unord/unord.multimap/bucket.pass.cpp index b1f9d36c..e53b492b 100644 --- a/test/containers/unord/unord.multimap/bucket.pass.cpp +++ b/test/containers/unord/unord.multimap/bucket.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -39,4 +41,25 @@ int main() for (size_t i = 0; i < 13; ++i) assert(c.bucket(i) == i % bc); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + const C c(std::begin(a), std::end(a)); + size_t bc = c.bucket_count(); + assert(bc >= 7); + for (size_t i = 0; i < 13; ++i) + assert(c.bucket(i) == i % bc); + } +#endif } diff --git a/test/containers/unord/unord.multimap/bucket_size.pass.cpp b/test/containers/unord/unord.multimap/bucket_size.pass.cpp index d8f784a2..79e53d2e 100644 --- a/test/containers/unord/unord.multimap/bucket_size.pass.cpp +++ b/test/containers/unord/unord.multimap/bucket_size.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -43,4 +45,29 @@ int main() assert(c.bucket_size(5) == 0); assert(c.bucket_size(6) == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + const C c(std::begin(a), std::end(a)); + assert(c.bucket_count() >= 7); + assert(c.bucket_size(0) == 0); + assert(c.bucket_size(1) == 2); + assert(c.bucket_size(2) == 2); + assert(c.bucket_size(3) == 1); + assert(c.bucket_size(4) == 1); + assert(c.bucket_size(5) == 0); + assert(c.bucket_size(6) == 0); + } +#endif } diff --git a/test/containers/unord/unord.multimap/count.pass.cpp b/test/containers/unord/unord.multimap/count.pass.cpp index 3bfac4da..a1d0432b 100644 --- a/test/containers/unord/unord.multimap/count.pass.cpp +++ b/test/containers/unord/unord.multimap/count.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -42,4 +44,28 @@ int main() assert(c.count(50) == 3); assert(c.count(5) == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(50, "fiftyA"), + P(50, "fiftyB"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + const C c(std::begin(a), std::end(a)); + assert(c.count(30) == 1); + assert(c.count(50) == 3); + assert(c.count(5) == 0); + } +#endif } diff --git a/test/containers/unord/unord.multimap/eq.pass.cpp b/test/containers/unord/unord.multimap/eq.pass.cpp index 6461cae1..b069ded5 100644 --- a/test/containers/unord/unord.multimap/eq.pass.cpp +++ b/test/containers/unord/unord.multimap/eq.pass.cpp @@ -23,6 +23,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -98,4 +100,82 @@ int main() assert( (c1 == c2)); assert(!(c1 != c2)); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(20, "twenty 2"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(50, "fifty 2"), + P(50, "fifty 3"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + const C c1(std::begin(a), std::end(a)); + const C c2; + assert(!(c1 == c2)); + assert( (c1 != c2)); + } + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(20, "twenty 2"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(50, "fifty 2"), + P(50, "fifty 3"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + const C c1(std::begin(a), std::end(a)); + const C c2 = c1; + assert( (c1 == c2)); + assert(!(c1 != c2)); + } + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(20, "twenty 2"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(50, "fifty 2"), + P(50, "fifty 3"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + C c1(std::begin(a), std::end(a)); + C c2 = c1; + c2.rehash(30); + assert( (c1 == c2)); + assert(!(c1 != c2)); + c2.insert(P(90, "ninety")); + assert(!(c1 == c2)); + assert( (c1 != c2)); + c1.insert(P(90, "ninety")); + assert( (c1 == c2)); + assert(!(c1 != c2)); + } +#endif } diff --git a/test/containers/unord/unord.multimap/equal_range_const.pass.cpp b/test/containers/unord/unord.multimap/equal_range_const.pass.cpp index 394ebb8b..bc0c703b 100644 --- a/test/containers/unord/unord.multimap/equal_range_const.pass.cpp +++ b/test/containers/unord/unord.multimap/equal_range_const.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -55,4 +57,41 @@ int main() assert(r.first->first == 50); assert(r.first->second == "fiftyB"); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef C::const_iterator I; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(50, "fiftyA"), + P(50, "fiftyB"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + const C c(std::begin(a), std::end(a)); + std::pair r = c.equal_range(30); + assert(std::distance(r.first, r.second) == 1); + assert(r.first->first == 30); + assert(r.first->second == "thirty"); + r = c.equal_range(5); + assert(std::distance(r.first, r.second) == 0); + r = c.equal_range(50); + assert(r.first->first == 50); + assert(r.first->second == "fifty"); + ++r.first; + assert(r.first->first == 50); + assert(r.first->second == "fiftyA"); + ++r.first; + assert(r.first->first == 50); + assert(r.first->second == "fiftyB"); + } +#endif } diff --git a/test/containers/unord/unord.multimap/equal_range_non_const.pass.cpp b/test/containers/unord/unord.multimap/equal_range_non_const.pass.cpp index 3fe83faa..8b78f70b 100644 --- a/test/containers/unord/unord.multimap/equal_range_non_const.pass.cpp +++ b/test/containers/unord/unord.multimap/equal_range_non_const.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -55,4 +57,41 @@ int main() assert(r.first->first == 50); assert(r.first->second == "fiftyB"); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef C::iterator I; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(50, "fiftyA"), + P(50, "fiftyB"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + C c(std::begin(a), std::end(a)); + std::pair r = c.equal_range(30); + assert(std::distance(r.first, r.second) == 1); + assert(r.first->first == 30); + assert(r.first->second == "thirty"); + r = c.equal_range(5); + assert(std::distance(r.first, r.second) == 0); + r = c.equal_range(50); + assert(r.first->first == 50); + assert(r.first->second == "fifty"); + ++r.first; + assert(r.first->first == 50); + assert(r.first->second == "fiftyA"); + ++r.first; + assert(r.first->first == 50); + assert(r.first->second == "fiftyB"); + } +#endif } diff --git a/test/containers/unord/unord.multimap/find_const.pass.cpp b/test/containers/unord/unord.multimap/find_const.pass.cpp index 8700dcf3..b967a513 100644 --- a/test/containers/unord/unord.multimap/find_const.pass.cpp +++ b/test/containers/unord/unord.multimap/find_const.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -42,4 +44,28 @@ int main() i = c.find(5); assert(i == c.cend()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + const C c(std::begin(a), std::end(a)); + C::const_iterator i = c.find(30); + assert(i->first == 30); + assert(i->second == "thirty"); + i = c.find(5); + assert(i == c.cend()); + } +#endif } diff --git a/test/containers/unord/unord.multimap/find_non_const.pass.cpp b/test/containers/unord/unord.multimap/find_non_const.pass.cpp index cb3aab9d..8da85ba9 100644 --- a/test/containers/unord/unord.multimap/find_non_const.pass.cpp +++ b/test/containers/unord/unord.multimap/find_non_const.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -42,4 +44,28 @@ int main() i = c.find(5); assert(i == c.end()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + C c(std::begin(a), std::end(a)); + C::iterator i = c.find(30); + assert(i->first == 30); + assert(i->second == "thirty"); + i = c.find(5); + assert(i == c.end()); + } +#endif } diff --git a/test/containers/unord/unord.multimap/iterators.pass.cpp b/test/containers/unord/unord.multimap/iterators.pass.cpp index 573fc630..c2fc44bc 100644 --- a/test/containers/unord/unord.multimap/iterators.pass.cpp +++ b/test/containers/unord/unord.multimap/iterators.pass.cpp @@ -24,6 +24,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -67,4 +69,49 @@ int main() assert(std::distance(c.cbegin(), c.cend()) == c.size()); C::const_iterator i; } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 7); + assert(c.size() == 6); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + C::iterator i; + i = c.begin(); + i->second = "ONE"; + assert(i->second == "ONE"); + } + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + const C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 7); + assert(c.size() == 6); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + C::const_iterator i; + } +#endif } diff --git a/test/containers/unord/unord.multimap/load_factor.pass.cpp b/test/containers/unord/unord.multimap/load_factor.pass.cpp index 250509d2..29cf689e 100644 --- a/test/containers/unord/unord.multimap/load_factor.pass.cpp +++ b/test/containers/unord/unord.multimap/load_factor.pass.cpp @@ -20,6 +20,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -45,4 +47,31 @@ int main() const C c; assert(c.load_factor() == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + const C c(std::begin(a), std::end(a)); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + } + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + const C c; + assert(c.load_factor() == 0); + } +#endif } diff --git a/test/containers/unord/unord.multimap/local_iterators.pass.cpp b/test/containers/unord/unord.multimap/local_iterators.pass.cpp index 7a292f90..695953d0 100644 --- a/test/containers/unord/unord.multimap/local_iterators.pass.cpp +++ b/test/containers/unord/unord.multimap/local_iterators.pass.cpp @@ -24,6 +24,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -282,4 +284,266 @@ int main() j = c.cend(b); assert(std::distance(i, j) == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + typedef C::local_iterator I; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 7); + C::size_type b = c.bucket(0); + I i = c.begin(b); + I j = c.end(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 2); + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + + b = c.bucket(2); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 2); + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + b = c.bucket(3); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(i->first == 3); + assert(i->second == "three"); + + b = c.bucket(4); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(i->first == 4); + assert(i->second == "four"); + + b = c.bucket(5); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(6); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 0); + } + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + typedef C::const_local_iterator I; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + const C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 7); + C::size_type b = c.bucket(0); + I i = c.begin(b); + I j = c.end(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 2); + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + + b = c.bucket(2); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 2); + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + b = c.bucket(3); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(i->first == 3); + assert(i->second == "three"); + + b = c.bucket(4); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(i->first == 4); + assert(i->second == "four"); + + b = c.bucket(5); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(6); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 0); + } + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + typedef C::const_local_iterator I; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 7); + C::size_type b = c.bucket(0); + I i = c.cbegin(b); + I j = c.cend(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 2); + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + + b = c.bucket(2); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 2); + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + b = c.bucket(3); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(i->first == 3); + assert(i->second == "three"); + + b = c.bucket(4); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(i->first == 4); + assert(i->second == "four"); + + b = c.bucket(5); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(6); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 0); + } + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + typedef C::const_local_iterator I; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + const C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 7); + C::size_type b = c.bucket(0); + I i = c.cbegin(b); + I j = c.cend(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 2); + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + + b = c.bucket(2); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 2); + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + b = c.bucket(3); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(i->first == 3); + assert(i->second == "three"); + + b = c.bucket(4); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(i->first == 4); + assert(i->second == "four"); + + b = c.bucket(5); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(6); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 0); + } +#endif } diff --git a/test/containers/unord/unord.multimap/max_bucket_count.pass.cpp b/test/containers/unord/unord.multimap/max_bucket_count.pass.cpp index e512eb88..0504db06 100644 --- a/test/containers/unord/unord.multimap/max_bucket_count.pass.cpp +++ b/test/containers/unord/unord.multimap/max_bucket_count.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -28,4 +30,14 @@ int main() const C c; assert(c.max_bucket_count() > 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef C::const_iterator I; + typedef std::pair P; + const C c; + assert(c.max_bucket_count() > 0); + } +#endif } diff --git a/test/containers/unord/unord.multimap/max_load_factor.pass.cpp b/test/containers/unord/unord.multimap/max_load_factor.pass.cpp index 1d30084f..5fcca6b1 100644 --- a/test/containers/unord/unord.multimap/max_load_factor.pass.cpp +++ b/test/containers/unord/unord.multimap/max_load_factor.pass.cpp @@ -20,6 +20,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -36,4 +38,22 @@ int main() c.max_load_factor(2.5); assert(c.max_load_factor() == 2.5); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + const C c; + assert(c.max_load_factor() == 1); + } + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + C c; + assert(c.max_load_factor() == 1); + c.max_load_factor(2.5); + assert(c.max_load_factor() == 2.5); + } +#endif } diff --git a/test/containers/unord/unord.multimap/max_size.pass.cpp b/test/containers/unord/unord.multimap/max_size.pass.cpp index b9e72a82..ac247d76 100644 --- a/test/containers/unord/unord.multimap/max_size.pass.cpp +++ b/test/containers/unord/unord.multimap/max_size.pass.cpp @@ -18,10 +18,19 @@ #include #include +#include "../../min_allocator.h" + int main() { { std::unordered_multimap u; assert(u.max_size() > 0); } +#if __cplusplus >= 201103L + { + std::unordered_multimap, std::equal_to, + min_allocator>> u; + assert(u.max_size() > 0); + } +#endif } diff --git a/test/containers/unord/unord.multimap/rehash.pass.cpp b/test/containers/unord/unord.multimap/rehash.pass.cpp index 42764360..e722c04a 100644 --- a/test/containers/unord/unord.multimap/rehash.pass.cpp +++ b/test/containers/unord/unord.multimap/rehash.pass.cpp @@ -20,14 +20,16 @@ #include #include -void test(const std::unordered_multimap& c) +#include "../../min_allocator.h" + +template +void test(const C& c) { - typedef std::unordered_multimap C; assert(c.size() == 6); - typedef std::pair Eq; + typedef std::pair Eq; Eq eq = c.equal_range(1); assert(std::distance(eq.first, eq.second) == 2); - C::const_iterator i = eq.first; + typename C::const_iterator i = eq.first; assert(i->first == 1); assert(i->second == "one"); ++i; @@ -85,4 +87,33 @@ int main() assert(c.bucket_count() == 31); test(c); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + test(c); + assert(c.bucket_count() >= 7); + c.rehash(3); + assert(c.bucket_count() == 7); + test(c); + c.max_load_factor(2); + c.rehash(3); + assert(c.bucket_count() == 3); + test(c); + c.rehash(31); + assert(c.bucket_count() == 31); + test(c); + } +#endif } diff --git a/test/containers/unord/unord.multimap/reserve.pass.cpp b/test/containers/unord/unord.multimap/reserve.pass.cpp index 3f652ad4..f13ae73b 100644 --- a/test/containers/unord/unord.multimap/reserve.pass.cpp +++ b/test/containers/unord/unord.multimap/reserve.pass.cpp @@ -19,7 +19,10 @@ #include #include -void test(const std::unordered_multimap& c) +#include "../../min_allocator.h" + +template +void test(const C& c) { assert(c.size() == 6); assert(c.find(1)->second == "one"); @@ -58,4 +61,33 @@ int main() assert(c.bucket_count() >= 16); test(c); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + test(c); + assert(c.bucket_count() >= 7); + c.reserve(3); + assert(c.bucket_count() == 7); + test(c); + c.max_load_factor(2); + c.reserve(3); + assert(c.bucket_count() == 3); + test(c); + c.reserve(31); + assert(c.bucket_count() >= 16); + test(c); + } +#endif } diff --git a/test/containers/unord/unord.multimap/swap_member.pass.cpp b/test/containers/unord/unord.multimap/swap_member.pass.cpp index 2388e526..41b34dda 100644 --- a/test/containers/unord/unord.multimap/swap_member.pass.cpp +++ b/test/containers/unord/unord.multimap/swap_member.pass.cpp @@ -23,6 +23,8 @@ #include "../../test_hash.h" #include "../../test_allocator.h" +#include "../../min_allocator.h" + int main() { { @@ -394,4 +396,190 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair P; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair P; + P a2[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(c1.find(10)->second == "ten"); + assert(c1.find(20)->second == "twenty"); + assert(c1.find(30)->second == "thirty"); + assert(c1.find(40)->second == "fourty"); + assert(c1.find(50)->second == "fifty"); + assert(c1.find(60)->second == "sixty"); + assert(c1.find(70)->second == "seventy"); + assert(c1.find(80)->second == "eighty"); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair P; + P a1[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 7); + assert(c2.size() == 6); + assert(c2.find(1)->second == "one"); + assert(next(c2.find(1))->second == "four"); + assert(c2.find(2)->second == "two"); + assert(next(c2.find(2))->second == "four"); + assert(c2.find(3)->second == "three"); + assert(c2.find(4)->second == "four"); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair P; + P a1[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + P a2[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(c1.find(10)->second == "ten"); + assert(c1.find(20)->second == "twenty"); + assert(c1.find(30)->second == "thirty"); + assert(c1.find(40)->second == "fourty"); + assert(c1.find(50)->second == "fifty"); + assert(c1.find(60)->second == "sixty"); + assert(c1.find(70)->second == "seventy"); + assert(c1.find(80)->second == "eighty"); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 7); + assert(c2.size() == 6); + assert(c2.find(1)->second == "one"); + assert(next(c2.find(1))->second == "four"); + assert(c2.find(2)->second == "two"); + assert(next(c2.find(2))->second == "four"); + assert(c2.find(3)->second == "three"); + assert(c2.find(4)->second == "four"); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multimap/types.pass.cpp b/test/containers/unord/unord.multimap/types.pass.cpp index 13cd3d76..369063cf 100644 --- a/test/containers/unord/unord.multimap/types.pass.cpp +++ b/test/containers/unord/unord.multimap/types.pass.cpp @@ -31,6 +31,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -48,4 +50,22 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp index bc3a2feb..1f7f4034 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -44,4 +45,25 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + C c(min_allocator >{}); + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp index 54d42dce..5c074ec4 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -144,4 +145,65 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef min_allocator > A; + typedef std::unordered_multimap >, + test_compare >, + A + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(3), + A() + ); + c = c0; + assert(c.bucket_count() == 7); + assert(c.size() == 6); + C::const_iterator i = c.cbegin(); + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + ++i; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + ++i; + assert(i->first == 3); + assert(i->second == "three"); + ++i; + assert(i->first == 4); + assert(i->second == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == A()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp index a8087086..a48f2ea0 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -83,5 +84,63 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef min_allocator > A; + typedef std::unordered_multimap >, + test_compare >, + A + > C; + typedef std::pair P; + C c = { + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + c = { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + assert(c.bucket_count() >= 7); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp index f01b6fda..721743ae 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -222,5 +223,72 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef min_allocator > A; + typedef std::unordered_multimap >, + test_compare >, + A + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(3), + A() + ); + c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp index 9dc90148..d46ba1c0 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -134,4 +135,59 @@ int main() assert(c.max_load_factor() == 1); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + C c = c0; + assert(c.bucket_count() == 7); + assert(c.size() == 6); + C::const_iterator i = c.cbegin(); + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + ++i; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + ++i; + assert(i->first == 3); + assert(i->second == "three"); + ++i; + assert(i->first == 4); + assert(i->second == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp index 4160a9f9..0e0d864d 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -79,4 +80,59 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + C c(c0, min_allocator >()); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + C::const_iterator i = c.cbegin(); + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + ++i; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + ++i; + assert(i->first == 3); + assert(i->second == "three"); + ++i; + assert(i->first == 4); + assert(i->second == "four"); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp index b40d43df..f450455d 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -44,4 +45,25 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + C c; + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp index a8c9e6bd..b4b2ac58 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -80,5 +81,60 @@ int main() assert(c.key_eq() == test_compare >()); assert((c.get_allocator() == test_allocator >())); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c = { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + assert(c.bucket_count() >= 7); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == min_allocator >())); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp index a4a265a5..7cb29274 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -82,5 +83,62 @@ int main() assert(c.key_eq() == test_compare >()); assert((c.get_allocator() == test_allocator >())); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7 + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == min_allocator >())); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp index 21155e69..7a2faaa6 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -83,5 +84,63 @@ int main() assert(c.key_eq() == test_compare >()); assert((c.get_allocator() == test_allocator >())); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == min_allocator >())); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp index 79936ff4..73c0ec28 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp @@ -24,6 +24,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -85,5 +86,64 @@ int main() assert(c.key_eq() == test_compare >(9)); assert((c.get_allocator() == test_allocator >())); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == min_allocator >())); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp index 53c7090f..bc59d64b 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp @@ -24,6 +24,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -86,5 +87,65 @@ int main() assert(c.key_eq() == test_compare >(9)); assert((c.get_allocator() == test_allocator >(10))); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == min_allocator >())); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp index 5ebb217b..3d4e5920 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -126,5 +127,106 @@ int main() assert(c0.empty()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c0(7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 0); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + + assert(c0.empty()); + } + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == min_allocator >())); + + assert(c0.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp index e40dc8b3..6f0cba8f 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp @@ -25,6 +25,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -157,5 +158,71 @@ int main() assert(c0.empty()); } +#if __cplusplus >= 201103L + { + typedef std::pair P; + typedef min_allocator> A; + typedef std::unordered_multimap >, + test_compare >, + A + > C; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + A() + ); + C c(std::move(c0), A()); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == min_allocator >())); + + assert(c0.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp index 5894e637..74171c71 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp @@ -26,6 +26,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -84,4 +85,61 @@ int main() assert(c.key_eq() == test_compare >()); assert((c.get_allocator() == test_allocator >())); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0]))); + assert(c.bucket_count() >= 7); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == min_allocator >())); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp index c02aa533..53a50de4 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp @@ -26,6 +26,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -86,4 +87,63 @@ int main() assert(c.key_eq() == test_compare >()); assert((c.get_allocator() == test_allocator >())); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 10 + ); + assert(c.bucket_count() == 11); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == min_allocator >())); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp index c3ce6189..02cfb2fa 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp @@ -27,6 +27,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -88,4 +89,64 @@ int main() assert(c.key_eq() == test_compare >()); assert((c.get_allocator() == test_allocator >())); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == min_allocator >())); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp index a13eba0e..e4fdfd3d 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp @@ -27,6 +27,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -89,4 +90,65 @@ int main() assert(c.key_eq() == test_compare >(9)); assert((c.get_allocator() == test_allocator >())); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == min_allocator >())); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp index 402ef6be..640de355 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp @@ -28,6 +28,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -91,4 +92,66 @@ int main() assert(c.key_eq() == test_compare >(9)); assert((c.get_allocator() == test_allocator >(10))); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator i = eq.first; + assert(i->first == 1); + assert(i->second == "one"); + ++i; + assert(i->first == 1); + assert(i->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + i = eq.first; + assert(i->first == 2); + assert(i->second == "two"); + ++i; + assert(i->first == 2); + assert(i->second == "four"); + + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 3); + assert(i->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + i = eq.first; + assert(i->first == 4); + assert(i->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == min_allocator >())); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp index f9b7eb7f..95ba70bb 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -44,4 +45,25 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + C c = 7; + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp index d16957c9..d9fac2ff 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -44,4 +45,25 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + C c(7); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp index afa25517..d691dd9c 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -46,4 +47,27 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + C c(7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp index 5a3c2628..9f902751 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -47,4 +48,28 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + C c(7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp index 6394ad46..23fae577 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -48,4 +49,29 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + C c(7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp index e2071fb6..a731f5b0 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -37,4 +39,23 @@ int main() c.clear(); assert(c.size() == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + c.clear(); + assert(c.size() == 0); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp index f05edd88..244419dc 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp @@ -20,6 +20,7 @@ #include #include "../../../Emplaceable.h" +#include "../../../min_allocator.h" int main() { @@ -44,5 +45,28 @@ int main() assert(r->first == 5); assert(r->second == Emplaceable(6, 7)); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + C c; + R r = c.emplace(3); + assert(c.size() == 1); + assert(r->first == 3); + assert(r->second == Emplaceable()); + + r = c.emplace(std::pair(4, Emplaceable(5, 6))); + assert(c.size() == 2); + assert(r->first == 4); + assert(r->second == Emplaceable(5, 6)); + + r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5), + std::forward_as_tuple(6, 7)); + assert(c.size() == 3); + assert(r->first == 5); + assert(r->second == Emplaceable(6, 7)); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp index 302451f1..576be4e3 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp @@ -20,6 +20,7 @@ #include #include "../../../Emplaceable.h" +#include "../../../min_allocator.h" int main() { @@ -53,5 +54,37 @@ int main() assert(r->first == 3); assert(r->second == Emplaceable(5, 6)); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + C c; + C::const_iterator e = c.end(); + R r = c.emplace_hint(e, 3); + assert(c.size() == 1); + assert(r->first == 3); + assert(r->second == Emplaceable()); + + r = c.emplace_hint(e, std::pair(3, Emplaceable(5, 6))); + assert(c.size() == 2); + assert(r->first == 3); + assert(r->second == Emplaceable(5, 6)); + assert(r == next(c.begin())); + + r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3), + std::forward_as_tuple(6, 7)); + assert(c.size() == 3); + assert(r->first == 3); + assert(r->second == Emplaceable(6, 7)); + assert(r == next(c.begin())); + r = c.begin(); + assert(r->first == 3); + assert(r->second == Emplaceable()); + r = next(r, 2); + assert(r->first == 3); + assert(r->second == Emplaceable(5, 6)); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp index b1df0f56..2b1d4d20 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -65,4 +67,51 @@ int main() assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + C::const_iterator i = c.find(2); + C::iterator j = c.erase(i); + + assert(c.size() == 5); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator k = eq.first; + assert(k->first == 1); + assert(k->second == "one"); + ++k; + assert(k->first == 1); + assert(k->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 2); + assert(k->second == "four"); + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 3); + assert(k->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 4); + assert(k->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp index 07f423b7..d59609a2 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -182,4 +184,168 @@ int main() assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.erase(5) == 0); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::const_iterator k = eq.first; + assert(k->first == 1); + assert(k->second == "one"); + ++k; + assert(k->first == 1); + assert(k->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + k = eq.first; + assert(k->first == 2); + assert(k->second == "two"); + ++k; + assert(k->first == 2); + assert(k->second == "four"); + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 3); + assert(k->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 4); + assert(k->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + + assert(c.erase(2) == 2); + assert(c.size() == 4); + eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + k = eq.first; + assert(k->first == 1); + assert(k->second == "one"); + ++k; + assert(k->first == 1); + assert(k->second == "four"); + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 3); + assert(k->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 4); + assert(k->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + + assert(c.erase(2) == 0); + assert(c.size() == 4); + eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + k = eq.first; + assert(k->first == 1); + assert(k->second == "one"); + ++k; + assert(k->first == 1); + assert(k->second == "four"); + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 3); + assert(k->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 4); + assert(k->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + + assert(c.erase(4) == 1); + assert(c.size() == 3); + eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + k = eq.first; + assert(k->first == 1); + assert(k->second == "one"); + ++k; + assert(k->first == 1); + assert(k->second == "four"); + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 3); + assert(k->second == "three"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + + assert(c.erase(4) == 0); + assert(c.size() == 3); + eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + k = eq.first; + assert(k->first == 1); + assert(k->second == "one"); + ++k; + assert(k->first == 1); + assert(k->second == "four"); + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 3); + assert(k->second == "three"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + + assert(c.erase(1) == 2); + assert(c.size() == 1); + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 3); + assert(k->second == "three"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + + assert(c.erase(1) == 0); + assert(c.size() == 1); + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 3); + assert(k->second == "three"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + + assert(c.erase(3) == 1); + assert(c.size() == 0); + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 0); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + + assert(c.erase(3) == 0); + assert(c.size() == 0); + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 0); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp index 08e77266..3ca3a361 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -96,4 +98,82 @@ int main() assert(c.size() == 0); assert(k == c.end()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + C::const_iterator i = c.find(2); + C::const_iterator j = next(i, 2); + C::iterator k = c.erase(i, i); + assert(k == i); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + k = eq.first; + assert(k->first == 1); + assert(k->second == "one"); + ++k; + assert(k->first == 1); + assert(k->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + k = eq.first; + assert(k->first == 2); + assert(k->second == "two"); + ++k; + assert(k->first == 2); + assert(k->second == "four"); + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 3); + assert(k->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 4); + assert(k->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + + k = c.erase(i, j); + assert(c.size() == 4); + eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + k = eq.first; + assert(k->first == 1); + assert(k->second == "one"); + ++k; + assert(k->first == 1); + assert(k->second == "four"); + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 3); + assert(k->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 4); + assert(k->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + + k = c.erase(c.cbegin(), c.cend()); + assert(c.size() == 0); + assert(k == c.end()); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp index 39bcefee..0528714d 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -45,4 +47,32 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef C::value_type P; + C c; + R r = c.insert(P(3.5, 3)); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert(P(3.5, 4)); + assert(c.size() == 2); + assert(r->first == 3.5); + assert(r->second == 4); + + r = c.insert(P(4.5, 4)); + assert(c.size() == 3); + assert(r->first == 4.5); + assert(r->second == 4); + + r = c.insert(P(5.5, 4)); + assert(c.size() == 4); + assert(r->first == 5.5); + assert(r->second == 4); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp index 038a2f3a..9e3f1280 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -46,4 +48,33 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef C::value_type P; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, P(3.5, 3)); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert(e, P(3.5, 4)); + assert(c.size() == 2); + assert(r->first == 3.5); + assert(r->second == 4); + + r = c.insert(e, P(4.5, 4)); + assert(c.size() == 3); + assert(r->first == 4.5); + assert(r->second == 4); + + r = c.insert(e, P(5.5, 4)); + assert(c.size() == 4); + assert(r->first == 5.5); + assert(r->second == 4); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp index fbcaa03a..c8dd38d5 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp @@ -21,6 +21,7 @@ #include #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -78,4 +79,62 @@ int main() assert(r->second == 4); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef std::pair P; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, P(3.5, 3)); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert(r, P(3.5, 4)); + assert(c.size() == 2); + assert(r->first == 3.5); + assert(r->second == 4); + + r = c.insert(e, P(4.5, 4)); + assert(c.size() == 3); + assert(r->first == 4.5); + assert(r->second == 4); + + r = c.insert(e, P(5.5, 4)); + assert(c.size() == 4); + assert(r->first == 5.5); + assert(r->second == 4); + } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef std::pair P; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, P(3, 3)); + assert(c.size() == 1); + assert(r->first == 3); + assert(r->second == 3); + + r = c.insert(r, P(3, 4)); + assert(c.size() == 2); + assert(r->first == 3); + assert(r->second == 4); + + r = c.insert(e, P(4, 4)); + assert(c.size() == 3); + assert(r->first == 4); + assert(r->second == 4); + + r = c.insert(e, P(5, 4)); + assert(c.size() == 4); + assert(r->first == 5); + assert(r->second == 4); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp index cab85081..0a7d8ea5 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp @@ -20,6 +20,7 @@ #include #include "test_iterators.h" +#include "../../../min_allocator.h" int main() { @@ -69,5 +70,53 @@ int main() assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + C c; + c.insert( + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + } + ); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::iterator k = eq.first; + assert(k->first == 1); + assert(k->second == "one"); + ++k; + assert(k->first == 1); + assert(k->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + k = eq.first; + assert(k->first == 2); + assert(k->second == "two"); + ++k; + assert(k->first == 2); + assert(k->second == "four"); + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 3); + assert(k->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 4); + assert(k->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp index fa445472..bda1958c 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp @@ -21,6 +21,7 @@ #include #include "test_iterators.h" +#include "../../../min_allocator.h" int main() { @@ -69,4 +70,52 @@ int main() assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair P; + P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c; + c.insert(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0]))); + assert(c.size() == 6); + typedef std::pair Eq; + Eq eq = c.equal_range(1); + assert(std::distance(eq.first, eq.second) == 2); + C::iterator k = eq.first; + assert(k->first == 1); + assert(k->second == "one"); + ++k; + assert(k->first == 1); + assert(k->second == "four"); + eq = c.equal_range(2); + assert(std::distance(eq.first, eq.second) == 2); + k = eq.first; + assert(k->first == 2); + assert(k->second == "two"); + ++k; + assert(k->first == 2); + assert(k->second == "four"); + eq = c.equal_range(3); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 3); + assert(k->second == "three"); + eq = c.equal_range(4); + assert(std::distance(eq.first, eq.second) == 1); + k = eq.first; + assert(k->first == 4); + assert(k->second == "four"); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + } +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp index dceada2e..c8bd1284 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp @@ -21,6 +21,7 @@ #include #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -76,4 +77,60 @@ int main() assert(r->second == 4); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef std::pair P; + C c; + R r = c.insert(P(3.5, 3)); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert(P(3.5, 4)); + assert(c.size() == 2); + assert(r->first == 3.5); + assert(r->second == 4); + + r = c.insert(P(4.5, 4)); + assert(c.size() == 3); + assert(r->first == 4.5); + assert(r->second == 4); + + r = c.insert(P(5.5, 4)); + assert(c.size() == 4); + assert(r->first == 5.5); + assert(r->second == 4); + } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef std::pair P; + C c; + R r = c.insert(P(3, 3)); + assert(c.size() == 1); + assert(r->first == 3); + assert(r->second == 3); + + r = c.insert(P(3, 4)); + assert(c.size() == 2); + assert(r->first == 3); + assert(r->second == 4); + + r = c.insert(P(4, 4)); + assert(c.size() == 3); + assert(r->first == 4); + assert(r->second == 4); + + r = c.insert(P(5, 4)); + assert(c.size() == 4); + assert(r->first == 5); + assert(r->second == 4); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp index d7f25700..0b5c5c3c 100644 --- a/test/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp +++ b/test/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -394,4 +395,190 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair P; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair P; + P a2[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(c1.find(10)->second == "ten"); + assert(c1.find(20)->second == "twenty"); + assert(c1.find(30)->second == "thirty"); + assert(c1.find(40)->second == "fourty"); + assert(c1.find(50)->second == "fifty"); + assert(c1.find(60)->second == "sixty"); + assert(c1.find(70)->second == "seventy"); + assert(c1.find(80)->second == "eighty"); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair P; + P a1[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 7); + assert(c2.size() == 6); + assert(c2.find(1)->second == "one"); + assert(next(c2.find(1))->second == "four"); + assert(c2.find(2)->second == "two"); + assert(next(c2.find(2))->second == "four"); + assert(c2.find(3)->second == "three"); + assert(c2.find(4)->second == "four"); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair P; + P a1[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + P a2[] = + { + P(10, "ten"), + P(20, "twenty"), + P(30, "thirty"), + P(40, "fourty"), + P(50, "fifty"), + P(60, "sixty"), + P(70, "seventy"), + P(80, "eighty"), + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(c1.find(10)->second == "ten"); + assert(c1.find(20)->second == "twenty"); + assert(c1.find(30)->second == "thirty"); + assert(c1.find(40)->second == "fourty"); + assert(c1.find(50)->second == "fifty"); + assert(c1.find(60)->second == "sixty"); + assert(c1.find(70)->second == "seventy"); + assert(c1.find(80)->second == "eighty"); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 7); + assert(c2.size() == 6); + assert(c2.find(1)->second == "one"); + assert(next(c2.find(1))->second == "four"); + assert(c2.find(2)->second == "two"); + assert(next(c2.find(2))->second == "four"); + assert(c2.find(3)->second == "three"); + assert(c2.find(4)->second == "four"); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/bucket.pass.cpp b/test/containers/unord/unord.multiset/bucket.pass.cpp index cab661be..99a72ab8 100644 --- a/test/containers/unord/unord.multiset/bucket.pass.cpp +++ b/test/containers/unord/unord.multiset/bucket.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -38,4 +40,25 @@ int main() for (size_t i = 0; i < 13; ++i) assert(c.bucket(i) == i % bc); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + const C c(std::begin(a), std::end(a)); + size_t bc = c.bucket_count(); + assert(bc >= 7); + for (size_t i = 0; i < 13; ++i) + assert(c.bucket(i) == i % bc); + } +#endif } diff --git a/test/containers/unord/unord.multiset/bucket_count.pass.cpp b/test/containers/unord/unord.multiset/bucket_count.pass.cpp index d2469b62..36c45b05 100644 --- a/test/containers/unord/unord.multiset/bucket_count.pass.cpp +++ b/test/containers/unord/unord.multiset/bucket_count.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -45,4 +47,33 @@ int main() const C c(std::begin(a), std::end(a)); assert(c.bucket_count() >= 11); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef C::const_iterator I; + typedef int P; + const C c; + assert(c.bucket_count() == 0); + } + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef C::const_iterator I; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + const C c(std::begin(a), std::end(a)); + assert(c.bucket_count() >= 11); + } +#endif } diff --git a/test/containers/unord/unord.multiset/bucket_size.pass.cpp b/test/containers/unord/unord.multiset/bucket_size.pass.cpp index 6e04ccf8..0f2977de 100644 --- a/test/containers/unord/unord.multiset/bucket_size.pass.cpp +++ b/test/containers/unord/unord.multiset/bucket_size.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -42,4 +44,29 @@ int main() assert(c.bucket_size(5) == 0); assert(c.bucket_size(6) == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + const C c(std::begin(a), std::end(a)); + assert(c.bucket_count() >= 7); + assert(c.bucket_size(0) == 0); + assert(c.bucket_size(1) == 2); + assert(c.bucket_size(2) == 2); + assert(c.bucket_size(3) == 1); + assert(c.bucket_size(4) == 1); + assert(c.bucket_size(5) == 0); + assert(c.bucket_size(6) == 0); + } +#endif } diff --git a/test/containers/unord/unord.multiset/clear.pass.cpp b/test/containers/unord/unord.multiset/clear.pass.cpp index 21c9a90b..73916312 100644 --- a/test/containers/unord/unord.multiset/clear.pass.cpp +++ b/test/containers/unord/unord.multiset/clear.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -36,4 +38,23 @@ int main() c.clear(); assert(c.size() == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + c.clear(); + assert(c.size() == 0); + } +#endif } diff --git a/test/containers/unord/unord.multiset/count.pass.cpp b/test/containers/unord/unord.multiset/count.pass.cpp index 74447ef2..426b5f88 100644 --- a/test/containers/unord/unord.multiset/count.pass.cpp +++ b/test/containers/unord/unord.multiset/count.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -41,4 +43,28 @@ int main() assert(c.count(50) == 3); assert(c.count(5) == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(50), + P(50), + P(60), + P(70), + P(80) + }; + const C c(std::begin(a), std::end(a)); + assert(c.count(30) == 1); + assert(c.count(50) == 3); + assert(c.count(5) == 0); + } +#endif } diff --git a/test/containers/unord/unord.multiset/emplace.pass.cpp b/test/containers/unord/unord.multiset/emplace.pass.cpp index b1513054..78478831 100644 --- a/test/containers/unord/unord.multiset/emplace.pass.cpp +++ b/test/containers/unord/unord.multiset/emplace.pass.cpp @@ -20,6 +20,7 @@ #include #include "../../Emplaceable.h" +#include "../../min_allocator.h" int main() { @@ -40,5 +41,24 @@ int main() assert(c.size() == 3); assert(*r == Emplaceable(5, 6)); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef C::iterator R; + C c; + R r = c.emplace(); + assert(c.size() == 1); + assert(*r == Emplaceable()); + + r = c.emplace(Emplaceable(5, 6)); + assert(c.size() == 2); + assert(*r == Emplaceable(5, 6)); + + r = c.emplace(5, 6); + assert(c.size() == 3); + assert(*r == Emplaceable(5, 6)); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.multiset/emplace_hint.pass.cpp b/test/containers/unord/unord.multiset/emplace_hint.pass.cpp index 1e529b0c..25a3b759 100644 --- a/test/containers/unord/unord.multiset/emplace_hint.pass.cpp +++ b/test/containers/unord/unord.multiset/emplace_hint.pass.cpp @@ -20,6 +20,7 @@ #include #include "../../Emplaceable.h" +#include "../../min_allocator.h" int main() { @@ -41,5 +42,25 @@ int main() assert(c.size() == 3); assert(*r == Emplaceable(5, 6)); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef C::iterator R; + C c; + C::const_iterator e = c.end(); + R r = c.emplace_hint(e); + assert(c.size() == 1); + assert(*r == Emplaceable()); + + r = c.emplace_hint(e, Emplaceable(5, 6)); + assert(c.size() == 2); + assert(*r == Emplaceable(5, 6)); + + r = c.emplace_hint(r, 5, 6); + assert(c.size() == 3); + assert(*r == Emplaceable(5, 6)); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.multiset/eq.pass.cpp b/test/containers/unord/unord.multiset/eq.pass.cpp index 6ac9ac8e..7350e444 100644 --- a/test/containers/unord/unord.multiset/eq.pass.cpp +++ b/test/containers/unord/unord.multiset/eq.pass.cpp @@ -22,6 +22,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -97,4 +99,82 @@ int main() assert( (c1 == c2)); assert(!(c1 != c2)); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(10), + P(20), + P(20), + P(30), + P(40), + P(50), + P(50), + P(50), + P(60), + P(70), + P(80) + }; + const C c1(std::begin(a), std::end(a)); + const C c2; + assert(!(c1 == c2)); + assert( (c1 != c2)); + } + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(10), + P(20), + P(20), + P(30), + P(40), + P(50), + P(50), + P(50), + P(60), + P(70), + P(80) + }; + const C c1(std::begin(a), std::end(a)); + const C c2 = c1; + assert( (c1 == c2)); + assert(!(c1 != c2)); + } + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(10), + P(20), + P(20), + P(30), + P(40), + P(50), + P(50), + P(50), + P(60), + P(70), + P(80) + }; + C c1(std::begin(a), std::end(a)); + C c2 = c1; + c2.rehash(30); + assert( (c1 == c2)); + assert(!(c1 != c2)); + c2.insert(P(90)); + assert(!(c1 == c2)); + assert( (c1 != c2)); + c1.insert(P(90)); + assert( (c1 == c2)); + assert(!(c1 != c2)); + } +#endif } diff --git a/test/containers/unord/unord.multiset/equal_range_const.pass.cpp b/test/containers/unord/unord.multiset/equal_range_const.pass.cpp index 91df1276..3fe242f5 100644 --- a/test/containers/unord/unord.multiset/equal_range_const.pass.cpp +++ b/test/containers/unord/unord.multiset/equal_range_const.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -51,4 +53,38 @@ int main() ++r.first; assert(*r.first == 50); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef C::const_iterator I; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(50), + P(50), + P(60), + P(70), + P(80) + }; + const C c(std::begin(a), std::end(a)); + std::pair r = c.equal_range(30); + assert(std::distance(r.first, r.second) == 1); + assert(*r.first == 30); + r = c.equal_range(5); + assert(std::distance(r.first, r.second) == 0); + r = c.equal_range(50); + assert(std::distance(r.first, r.second) == 3); + assert(*r.first == 50); + ++r.first; + assert(*r.first == 50); + ++r.first; + assert(*r.first == 50); + } +#endif } diff --git a/test/containers/unord/unord.multiset/equal_range_non_const.pass.cpp b/test/containers/unord/unord.multiset/equal_range_non_const.pass.cpp index c0f974ae..ebda719b 100644 --- a/test/containers/unord/unord.multiset/equal_range_non_const.pass.cpp +++ b/test/containers/unord/unord.multiset/equal_range_non_const.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -51,4 +53,38 @@ int main() ++r.first; assert(*r.first == 50); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef C::iterator I; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(50), + P(50), + P(60), + P(70), + P(80) + }; + C c(std::begin(a), std::end(a)); + std::pair r = c.equal_range(30); + assert(std::distance(r.first, r.second) == 1); + assert(*r.first == 30); + r = c.equal_range(5); + assert(std::distance(r.first, r.second) == 0); + r = c.equal_range(50); + assert(std::distance(r.first, r.second) == 3); + assert(*r.first == 50); + ++r.first; + assert(*r.first == 50); + ++r.first; + assert(*r.first == 50); + } +#endif } diff --git a/test/containers/unord/unord.multiset/erase_const_iter.pass.cpp b/test/containers/unord/unord.multiset/erase_const_iter.pass.cpp index 658f50fb..6cb2c72c 100644 --- a/test/containers/unord/unord.multiset/erase_const_iter.pass.cpp +++ b/test/containers/unord/unord.multiset/erase_const_iter.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -41,4 +43,28 @@ int main() assert(c.count(3) == 1); assert(c.count(4) == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + C::const_iterator i = c.find(2); + C::iterator j = c.erase(i); + assert(c.size() == 5); + assert(c.count(1) == 2); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/erase_key.pass.cpp b/test/containers/unord/unord.multiset/erase_key.pass.cpp index ecb974ea..b0b68158 100644 --- a/test/containers/unord/unord.multiset/erase_key.pass.cpp +++ b/test/containers/unord/unord.multiset/erase_key.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -77,4 +79,63 @@ int main() assert(c.erase(3) == 0); assert(c.size() == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.erase(5) == 0); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + + assert(c.erase(2) == 2); + assert(c.size() == 4); + assert(c.count(1) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + + assert(c.erase(2) == 0); + assert(c.size() == 4); + assert(c.count(1) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + + assert(c.erase(4) == 1); + assert(c.size() == 3); + assert(c.count(1) == 2); + assert(c.count(3) == 1); + + assert(c.erase(4) == 0); + assert(c.size() == 3); + assert(c.count(1) == 2); + assert(c.count(3) == 1); + + assert(c.erase(1) == 2); + assert(c.size() == 1); + assert(c.count(3) == 1); + + assert(c.erase(1) == 0); + assert(c.size() == 1); + assert(c.count(3) == 1); + + assert(c.erase(3) == 1); + assert(c.size() == 0); + + assert(c.erase(3) == 0); + assert(c.size() == 0); + } +#endif } diff --git a/test/containers/unord/unord.multiset/erase_range.pass.cpp b/test/containers/unord/unord.multiset/erase_range.pass.cpp index cf277751..601c4b3b 100644 --- a/test/containers/unord/unord.multiset/erase_range.pass.cpp +++ b/test/containers/unord/unord.multiset/erase_range.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -53,4 +55,40 @@ int main() assert(c.size() == 0); assert(k == c.end()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + C::const_iterator i = c.find(2); + C::const_iterator j = next(i, 2); + C::iterator k = c.erase(i, i); + assert(k == i); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + + k = c.erase(i, j); + assert(c.size() == 4); + assert(c.count(1) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + + k = c.erase(c.cbegin(), c.cend()); + assert(c.size() == 0); + assert(k == c.end()); + } +#endif } diff --git a/test/containers/unord/unord.multiset/find_const.pass.cpp b/test/containers/unord/unord.multiset/find_const.pass.cpp index b39e46f4..dbe4eae5 100644 --- a/test/containers/unord/unord.multiset/find_const.pass.cpp +++ b/test/containers/unord/unord.multiset/find_const.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -40,4 +42,27 @@ int main() i = c.find(5); assert(i == c.cend()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + const C c(std::begin(a), std::end(a)); + C::const_iterator i = c.find(30); + assert(*i == 30); + i = c.find(5); + assert(i == c.cend()); + } +#endif } diff --git a/test/containers/unord/unord.multiset/find_non_const.pass.cpp b/test/containers/unord/unord.multiset/find_non_const.pass.cpp index e6ac8551..af630180 100644 --- a/test/containers/unord/unord.multiset/find_non_const.pass.cpp +++ b/test/containers/unord/unord.multiset/find_non_const.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -40,4 +42,27 @@ int main() i = c.find(5); assert(i == c.cend()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + C c(std::begin(a), std::end(a)); + C::iterator i = c.find(30); + assert(*i == 30); + i = c.find(5); + assert(i == c.cend()); + } +#endif } diff --git a/test/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp b/test/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp index 6e4b9a10..ce469976 100644 --- a/test/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp +++ b/test/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -41,4 +43,28 @@ int main() assert(c.size() == 4); assert(*r == 5.5); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef C::iterator R; + typedef C::value_type P; + C c; + R r = c.insert(P(3.5)); + assert(c.size() == 1); + assert(*r == 3.5); + + r = c.insert(P(3.5)); + assert(c.size() == 2); + assert(*r == 3.5); + + r = c.insert(P(4.5)); + assert(c.size() == 3); + assert(*r == 4.5); + + r = c.insert(P(5.5)); + assert(c.size() == 4); + assert(*r == 5.5); + } +#endif } diff --git a/test/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp b/test/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp index 4d949e49..02b8375f 100644 --- a/test/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp +++ b/test/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -42,4 +44,29 @@ int main() assert(c.size() == 4); assert(*r == 5.5); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef C::iterator R; + typedef C::value_type P; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, P(3.5)); + assert(c.size() == 1); + assert(*r == 3.5); + + r = c.insert(e, P(3.5)); + assert(c.size() == 2); + assert(*r == 3.5); + + r = c.insert(e, P(4.5)); + assert(c.size() == 3); + assert(*r == 4.5); + + r = c.insert(e, P(5.5)); + assert(c.size() == 4); + assert(*r == 5.5); + } +#endif } diff --git a/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp b/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp index 8239b343..590baa05 100644 --- a/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp +++ b/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp @@ -19,6 +19,7 @@ #include #include "../../MoveOnly.h" +#include "../../min_allocator.h" int main() { @@ -68,4 +69,54 @@ int main() assert(*r == 5); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef C::iterator R; + typedef double P; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, P(3.5)); + assert(c.size() == 1); + assert(*r == 3.5); + + r = c.insert(r, P(3.5)); + assert(c.size() == 2); + assert(*r == 3.5); + + r = c.insert(e, P(4.5)); + assert(c.size() == 3); + assert(*r == 4.5); + + r = c.insert(e, P(5.5)); + assert(c.size() == 4); + assert(*r == 5.5); + } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef C::iterator R; + typedef MoveOnly P; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, P(3)); + assert(c.size() == 1); + assert(*r == 3); + + r = c.insert(r, P(3)); + assert(c.size() == 2); + assert(*r == 3); + + r = c.insert(e, P(4)); + assert(c.size() == 3); + assert(*r == 4); + + r = c.insert(e, P(5)); + assert(c.size() == 4); + assert(*r == 5); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/containers/unord/unord.multiset/insert_init.pass.cpp b/test/containers/unord/unord.multiset/insert_init.pass.cpp index db82f65a..7a9d3f7c 100644 --- a/test/containers/unord/unord.multiset/insert_init.pass.cpp +++ b/test/containers/unord/unord.multiset/insert_init.pass.cpp @@ -19,6 +19,7 @@ #include #include "test_iterators.h" +#include "../../min_allocator.h" int main() { @@ -43,5 +44,28 @@ int main() assert(c.count(3) == 1); assert(c.count(4) == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + C c; + c.insert( + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + } + ); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multiset/insert_range.pass.cpp b/test/containers/unord/unord.multiset/insert_range.pass.cpp index 93d5e837..28637f5f 100644 --- a/test/containers/unord/unord.multiset/insert_range.pass.cpp +++ b/test/containers/unord/unord.multiset/insert_range.pass.cpp @@ -20,6 +20,7 @@ #include #include "test_iterators.h" +#include "../../min_allocator.h" int main() { @@ -43,4 +44,27 @@ int main() assert(c.count(3) == 1); assert(c.count(4) == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c; + c.insert(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0]))); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/insert_rvalue.pass.cpp b/test/containers/unord/unord.multiset/insert_rvalue.pass.cpp index dd33e4b0..7cddb0d9 100644 --- a/test/containers/unord/unord.multiset/insert_rvalue.pass.cpp +++ b/test/containers/unord/unord.multiset/insert_rvalue.pass.cpp @@ -19,6 +19,7 @@ #include #include "../../MoveOnly.h" +#include "../../min_allocator.h" int main() { @@ -66,4 +67,52 @@ int main() assert(*r == 5); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef C::iterator R; + typedef double P; + C c; + R r = c.insert(P(3.5)); + assert(c.size() == 1); + assert(*r == 3.5); + + r = c.insert(P(3.5)); + assert(c.size() == 2); + assert(*r == 3.5); + + r = c.insert(P(4.5)); + assert(c.size() == 3); + assert(*r == 4.5); + + r = c.insert(P(5.5)); + assert(c.size() == 4); + assert(*r == 5.5); + } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef C::iterator R; + typedef MoveOnly P; + C c; + R r = c.insert(P(3)); + assert(c.size() == 1); + assert(*r == 3); + + r = c.insert(P(3)); + assert(c.size() == 2); + assert(*r == 3); + + r = c.insert(P(4)); + assert(c.size() == 3); + assert(*r == 4); + + r = c.insert(P(5)); + assert(c.size() == 4); + assert(*r == 5); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/containers/unord/unord.multiset/iterators.pass.cpp b/test/containers/unord/unord.multiset/iterators.pass.cpp index 1da86067..ddfc3742 100644 --- a/test/containers/unord/unord.multiset/iterators.pass.cpp +++ b/test/containers/unord/unord.multiset/iterators.pass.cpp @@ -23,6 +23,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -63,4 +65,46 @@ int main() assert(std::distance(c.cbegin(), c.cend()) == c.size()); C::const_iterator i; } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 7); + assert(c.size() == 6); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + C::iterator i; + } + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + const C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 7); + assert(c.size() == 6); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + C::const_iterator i; + } +#endif } diff --git a/test/containers/unord/unord.multiset/load_factor.pass.cpp b/test/containers/unord/unord.multiset/load_factor.pass.cpp index 664a2a79..c6e4825f 100644 --- a/test/containers/unord/unord.multiset/load_factor.pass.cpp +++ b/test/containers/unord/unord.multiset/load_factor.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -44,4 +46,31 @@ int main() const C c; assert(c.load_factor() == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + const C c(std::begin(a), std::end(a)); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + } + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + const C c; + assert(c.load_factor() == 0); + } +#endif } diff --git a/test/containers/unord/unord.multiset/local_iterators.pass.cpp b/test/containers/unord/unord.multiset/local_iterators.pass.cpp index 51481ac4..6cc07b60 100644 --- a/test/containers/unord/unord.multiset/local_iterators.pass.cpp +++ b/test/containers/unord/unord.multiset/local_iterators.pass.cpp @@ -23,6 +23,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -257,4 +259,242 @@ int main() j = c.cend(b); assert(std::distance(i, j) == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + typedef C::local_iterator I; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 7); + C::size_type b = c.bucket(0); + I i = c.begin(b); + I j = c.end(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 2); + assert(*i == 1); + ++i; + assert(*i == 1); + + b = c.bucket(2); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 2); + assert(*i == 2); + ++i; + assert(*i == 2); + + b = c.bucket(3); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(*i == 3); + + b = c.bucket(4); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(*i == 4); + + b = c.bucket(5); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(6); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 0); + } + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + typedef C::const_local_iterator I; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + const C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 7); + C::size_type b = c.bucket(0); + I i = c.begin(b); + I j = c.end(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 2); + assert(*i == 1); + ++i; + assert(*i == 1); + + b = c.bucket(2); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 2); + assert(*i == 2); + ++i; + assert(*i == 2); + + b = c.bucket(3); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(*i == 3); + + b = c.bucket(4); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(*i == 4); + + b = c.bucket(5); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(6); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 0); + } + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + typedef C::const_local_iterator I; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 7); + C::size_type b = c.bucket(0); + I i = c.cbegin(b); + I j = c.cend(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 2); + assert(*i == 1); + ++i; + assert(*i == 1); + + b = c.bucket(2); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 2); + assert(*i == 2); + ++i; + assert(*i == 2); + + b = c.bucket(3); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(*i == 3); + + b = c.bucket(4); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(*i == 4); + + b = c.bucket(5); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(6); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 0); + } + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + typedef C::const_local_iterator I; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + const C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 7); + C::size_type b = c.bucket(0); + I i = c.cbegin(b); + I j = c.cend(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 2); + assert(*i == 1); + ++i; + assert(*i == 1); + + b = c.bucket(2); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 2); + assert(*i == 2); + ++i; + assert(*i == 2); + + b = c.bucket(3); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(*i == 3); + + b = c.bucket(4); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(*i == 4); + + b = c.bucket(5); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(6); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 0); + } +#endif } diff --git a/test/containers/unord/unord.multiset/max_bucket_count.pass.cpp b/test/containers/unord/unord.multiset/max_bucket_count.pass.cpp index db6d9887..fa55a1f8 100644 --- a/test/containers/unord/unord.multiset/max_bucket_count.pass.cpp +++ b/test/containers/unord/unord.multiset/max_bucket_count.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -25,4 +27,12 @@ int main() const C c; assert(c.max_bucket_count() > 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + const C c; + assert(c.max_bucket_count() > 0); + } +#endif } diff --git a/test/containers/unord/unord.multiset/max_load_factor.pass.cpp b/test/containers/unord/unord.multiset/max_load_factor.pass.cpp index d1212d8a..f2beb8fe 100644 --- a/test/containers/unord/unord.multiset/max_load_factor.pass.cpp +++ b/test/containers/unord/unord.multiset/max_load_factor.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -35,4 +37,22 @@ int main() c.max_load_factor(2.5); assert(c.max_load_factor() == 2.5); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + const C c; + assert(c.max_load_factor() == 1); + } + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + C c; + assert(c.max_load_factor() == 1); + c.max_load_factor(2.5); + assert(c.max_load_factor() == 2.5); + } +#endif } diff --git a/test/containers/unord/unord.multiset/max_size.pass.cpp b/test/containers/unord/unord.multiset/max_size.pass.cpp index fa2938ea..23171294 100644 --- a/test/containers/unord/unord.multiset/max_size.pass.cpp +++ b/test/containers/unord/unord.multiset/max_size.pass.cpp @@ -18,10 +18,19 @@ #include #include +#include "../../min_allocator.h" + int main() { { std::unordered_multiset u; assert(u.max_size() > 0); } +#if __cplusplus >= 201103L + { + std::unordered_multiset, + std::equal_to, min_allocator> u; + assert(u.max_size() > 0); + } +#endif } diff --git a/test/containers/unord/unord.multiset/rehash.pass.cpp b/test/containers/unord/unord.multiset/rehash.pass.cpp index e82664bf..9358c327 100644 --- a/test/containers/unord/unord.multiset/rehash.pass.cpp +++ b/test/containers/unord/unord.multiset/rehash.pass.cpp @@ -18,7 +18,10 @@ #include #include -void test(const std::unordered_multiset& c) +#include "../../min_allocator.h" + +template +void test(const C& c) { assert(c.size() == 6); assert(c.count(1) == 2); @@ -55,4 +58,33 @@ int main() assert(c.bucket_count() == 31); test(c); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + test(c); + assert(c.bucket_count() >= 7); + c.rehash(3); + assert(c.bucket_count() == 7); + test(c); + c.max_load_factor(2); + c.rehash(3); + assert(c.bucket_count() == 3); + test(c); + c.rehash(31); + assert(c.bucket_count() == 31); + test(c); + } +#endif } diff --git a/test/containers/unord/unord.multiset/reserve.pass.cpp b/test/containers/unord/unord.multiset/reserve.pass.cpp index bce82132..e1c9e0a0 100644 --- a/test/containers/unord/unord.multiset/reserve.pass.cpp +++ b/test/containers/unord/unord.multiset/reserve.pass.cpp @@ -18,7 +18,10 @@ #include #include -void test(const std::unordered_multiset& c) +#include "../../min_allocator.h" + +template +void test(const C& c) { assert(c.size() == 6); assert(c.count(1) == 2); @@ -55,4 +58,33 @@ int main() assert(c.bucket_count() >= 16); test(c); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + test(c); + assert(c.bucket_count() >= 7); + c.reserve(3); + assert(c.bucket_count() == 7); + test(c); + c.max_load_factor(2); + c.reserve(3); + assert(c.bucket_count() == 3); + test(c); + c.reserve(31); + assert(c.bucket_count() >= 16); + test(c); + } +#endif } diff --git a/test/containers/unord/unord.multiset/swap_member.pass.cpp b/test/containers/unord/unord.multiset/swap_member.pass.cpp index 3392eccb..3a7c506f 100644 --- a/test/containers/unord/unord.multiset/swap_member.pass.cpp +++ b/test/containers/unord/unord.multiset/swap_member.pass.cpp @@ -21,6 +21,7 @@ #include "../../test_compare.h" #include "../../test_hash.h" #include "../../test_allocator.h" +#include "../../min_allocator.h" int main() { @@ -385,4 +386,186 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset C; + typedef int P; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset C; + typedef int P; + P a2[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(*c1.find(10) == 10); + assert(*c1.find(20) == 20); + assert(*c1.find(30) == 30); + assert(*c1.find(40) == 40); + assert(*c1.find(50) == 50); + assert(*c1.find(60) == 60); + assert(*c1.find(70) == 70); + assert(*c1.find(80) == 80); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset C; + typedef int P; + P a1[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 7); + assert(c2.size() == 6); + assert(c2.count(1) == 2); + assert(c2.count(2) == 2); + assert(c2.count(3) == 1); + assert(c2.count(4) == 1); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset C; + typedef int P; + P a1[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + P a2[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(*c1.find(10) == 10); + assert(*c1.find(20) == 20); + assert(*c1.find(30) == 30); + assert(*c1.find(40) == 40); + assert(*c1.find(50) == 50); + assert(*c1.find(60) == 60); + assert(*c1.find(70) == 70); + assert(*c1.find(80) == 80); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 7); + assert(c2.size() == 6); + assert(c2.count(1) == 2); + assert(c2.count(2) == 2); + assert(c2.count(3) == 1); + assert(c2.count(4) == 1); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/types.pass.cpp b/test/containers/unord/unord.multiset/types.pass.cpp index 67a8eb6f..5d7fa3aa 100644 --- a/test/containers/unord/unord.multiset/types.pass.cpp +++ b/test/containers/unord/unord.multiset/types.pass.cpp @@ -30,6 +30,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -46,4 +48,21 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp index 2299b5e7..db8ba0e7 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -42,4 +43,23 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + C c(min_allocator{}); + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp index dbeda949..5f5cac2f 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -131,4 +132,59 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef min_allocator A; + typedef std::unordered_multiset >, + test_compare >, + A + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(3), + A() + ); + c = c0; + assert(c.bucket_count() == 7); + assert(c.size() == 6); + C::const_iterator i = c.cbegin(); + assert(*i == 1); + ++i; + assert(*i == 1); + ++i; + assert(*i == 2); + ++i; + assert(*i == 2); + ++i; + assert(*i == 3); + ++i; + assert(*i == 4); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == A()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp index d1c3cb17..23ca1fc4 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -58,5 +59,39 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef min_allocator A; + typedef std::unordered_multiset >, + test_compare >, + A + > C; + typedef int P; + C c = { + P(4), + P(1), + P(2) + }; + c = { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + assert(c.bucket_count() >= 7); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp index 881a0d77..292f50ff 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -169,5 +170,105 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef test_allocator A; + typedef std::unordered_multiset >, + test_compare >, + A + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(3), + A() + ); + c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + C::const_iterator i = c.cbegin(); + assert(*i == 4); + ++i; + assert(*i == 3); + ++i; + assert(*i == 2); + ++i; + assert(*i == 2); + ++i; + assert(*i == 1); + ++i; + assert(*i == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == A()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef min_allocator A; + typedef std::unordered_multiset >, + test_compare >, + A + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(3), + A() + ); + c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == A()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp index 20f5644e..300a4db8 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -119,4 +120,52 @@ int main() assert(c.max_load_factor() == 1); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + C c = c0; + assert(c.bucket_count() == 7); + assert(c.size() == 6); + C::const_iterator i = c.cbegin(); + assert(*i == 1); + ++i; + assert(*i == 1); + ++i; + assert(*i == 2); + ++i; + assert(*i == 2); + ++i; + assert(*i == 3); + ++i; + assert(*i == 4); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp index b3357a80..636f6449 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -71,4 +72,52 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + C c(c0, min_allocator()); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + C::const_iterator i = c.cbegin(); + assert(*i == 1); + ++i; + assert(*i == 1); + ++i; + assert(*i == 2); + ++i; + assert(*i == 2); + ++i; + assert(*i == 3); + ++i; + assert(*i == 4); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp index d2761b18..4546d597 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -42,4 +43,23 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + C c; + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (min_allocator())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp index ce16ebf5..29729b5a 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -56,5 +57,37 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + typedef int P; + C c = { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + assert(c.bucket_count() >= 7); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp index b473d261..f16c2321 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -58,5 +59,39 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7 + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp index 4b474fc5..53bf1953 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -60,5 +61,40 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp index ca8fde42..bd2c3188 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -61,5 +62,41 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp index ba1ec05b..d7c69359 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -62,5 +63,42 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp index 969d35d7..e24d8f38 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -101,5 +102,82 @@ int main() assert(c0.empty()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 0); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + + assert(c0.empty()); + } + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + + assert(c0.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp index 77d6d81b..e5283168 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -116,5 +117,97 @@ int main() assert(c0.empty()); } +#if __cplusplus >= 201103L + { + typedef int P; + typedef min_allocator A; + typedef std::unordered_multiset >, + test_compare >, + A + > C; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + A() + ); + C c(std::move(c0), A()); + assert(c.bucket_count() >= 7); + assert(c.size() == 6); + C::const_iterator i = c.cbegin(); + assert(*i == 4); + ++i; + assert(*i == 3); + ++i; + assert(*i == 2); + ++i; + assert(*i == 2); + ++i; + assert(*i == 1); + ++i; + assert(*i == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == A()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + + assert(c0.empty()); + } + { + typedef int P; + typedef min_allocator A; + typedef std::unordered_multiset >, + test_compare >, + A + > C; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + A() + ); + C c(std::move(c0), A()); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == A()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + + assert(c0.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp index 92a5e98d..8c0828ae 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp @@ -24,6 +24,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -59,4 +60,38 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0]))); + assert(c.bucket_count() >= 7); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp index 6d2aff60..5fa494b9 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp @@ -24,6 +24,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -61,4 +62,40 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7 + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp index fbec9836..bace36a8 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp @@ -25,6 +25,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -63,4 +64,41 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp index c7018756..a97750eb 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp @@ -25,6 +25,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -64,4 +65,42 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp index ba94ac43..41f2e277 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp @@ -26,6 +26,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -66,4 +67,43 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp index 11010e4a..1916b6b8 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -42,4 +43,23 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + C c = 7; + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (min_allocator())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp index afeedb4a..4e990374 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -42,4 +43,23 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + C c(7); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (min_allocator())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp index bc5b49a6..19f4440a 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -44,4 +45,25 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + C c(7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (min_allocator())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp index 106775ff..59eba532 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -45,4 +46,26 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + C c(7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == (min_allocator())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp index b90044da..ca71ab37 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -46,4 +47,27 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset >, + test_compare >, + min_allocator + > C; + C c(7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == (min_allocator())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp index f56e2474..b75816a9 100644 --- a/test/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp +++ b/test/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp @@ -21,6 +21,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -385,4 +386,186 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset C; + typedef int P; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset C; + typedef int P; + P a2[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(*c1.find(10) == 10); + assert(*c1.find(20) == 20); + assert(*c1.find(30) == 30); + assert(*c1.find(40) == 40); + assert(*c1.find(50) == 50); + assert(*c1.find(60) == 60); + assert(*c1.find(70) == 70); + assert(*c1.find(80) == 80); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset C; + typedef int P; + P a1[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 7); + assert(c2.size() == 6); + assert(c2.count(1) == 2); + assert(c2.count(2) == 2); + assert(c2.count(3) == 1); + assert(c2.count(4) == 1); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset C; + typedef int P; + P a1[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + P a2[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(*c1.find(10) == 10); + assert(*c1.find(20) == 20); + assert(*c1.find(30) == 30); + assert(*c1.find(40) == 40); + assert(*c1.find(50) == 50); + assert(*c1.find(60) == 60); + assert(*c1.find(70) == 70); + assert(*c1.find(80) == 80); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 7); + assert(c2.size() == 6); + assert(c2.count(1) == 2); + assert(c2.count(2) == 2); + assert(c2.count(3) == 1); + assert(c2.count(4) == 1); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/bucket.pass.cpp b/test/containers/unord/unord.set/bucket.pass.cpp index bdbd523a..25f65815 100644 --- a/test/containers/unord/unord.set/bucket.pass.cpp +++ b/test/containers/unord/unord.set/bucket.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -38,4 +40,24 @@ int main() for (size_t i = 0; i < 13; ++i) assert(c.bucket(i) == i % bc); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + const C c(std::begin(a), std::end(a)); + size_t bc = c.bucket_count(); + assert(bc >= 5); + for (size_t i = 0; i < 13; ++i) + assert(c.bucket(i) == i % bc); + } +#endif } diff --git a/test/containers/unord/unord.set/bucket_count.pass.cpp b/test/containers/unord/unord.set/bucket_count.pass.cpp index 5cfc71d5..649aaa15 100644 --- a/test/containers/unord/unord.set/bucket_count.pass.cpp +++ b/test/containers/unord/unord.set/bucket_count.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -45,4 +47,31 @@ int main() const C c(std::begin(a), std::end(a)); assert(c.bucket_count() >= 11); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef C::const_iterator I; + typedef int P; + const C c; + assert(c.bucket_count() == 0); + } + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef C::const_iterator I; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + const C c(std::begin(a), std::end(a)); + assert(c.bucket_count() >= 11); + } +#endif } diff --git a/test/containers/unord/unord.set/bucket_size.pass.cpp b/test/containers/unord/unord.set/bucket_size.pass.cpp index 3c0f120e..aecb2585 100644 --- a/test/containers/unord/unord.set/bucket_size.pass.cpp +++ b/test/containers/unord/unord.set/bucket_size.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -40,4 +42,26 @@ int main() assert(c.bucket_size(3) == 1); assert(c.bucket_size(4) == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + const C c(std::begin(a), std::end(a)); + assert(c.bucket_count() >= 5); + assert(c.bucket_size(0) == 0); + assert(c.bucket_size(1) == 1); + assert(c.bucket_size(2) == 1); + assert(c.bucket_size(3) == 1); + assert(c.bucket_size(4) == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/clear.pass.cpp b/test/containers/unord/unord.set/clear.pass.cpp index 3052087e..1f97ab75 100644 --- a/test/containers/unord/unord.set/clear.pass.cpp +++ b/test/containers/unord/unord.set/clear.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -36,4 +38,22 @@ int main() c.clear(); assert(c.size() == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + c.clear(); + assert(c.size() == 0); + } +#endif } diff --git a/test/containers/unord/unord.set/count.pass.cpp b/test/containers/unord/unord.set/count.pass.cpp index bbd02d63..d850a7e5 100644 --- a/test/containers/unord/unord.set/count.pass.cpp +++ b/test/containers/unord/unord.set/count.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -41,4 +43,27 @@ int main() assert(c.count(50) == 1); assert(c.count(5) == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(50), + P(50), + P(60), + P(70), + P(80) + }; + const C c(std::begin(a), std::end(a)); + assert(c.count(30) == 1); + assert(c.count(50) == 1); + assert(c.count(5) == 0); + } +#endif } diff --git a/test/containers/unord/unord.set/emplace.pass.cpp b/test/containers/unord/unord.set/emplace.pass.cpp index 70ffeb9b..a6faecb3 100644 --- a/test/containers/unord/unord.set/emplace.pass.cpp +++ b/test/containers/unord/unord.set/emplace.pass.cpp @@ -20,6 +20,7 @@ #include #include "../../Emplaceable.h" +#include "../../min_allocator.h" int main() { @@ -43,5 +44,27 @@ int main() assert(*r.first == Emplaceable(5, 6)); assert(!r.second); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef std::pair R; + C c; + R r = c.emplace(); + assert(c.size() == 1); + assert(*r.first == Emplaceable()); + assert(r.second); + + r = c.emplace(Emplaceable(5, 6)); + assert(c.size() == 2); + assert(*r.first == Emplaceable(5, 6)); + assert(r.second); + + r = c.emplace(5, 6); + assert(c.size() == 2); + assert(*r.first == Emplaceable(5, 6)); + assert(!r.second); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.set/emplace_hint.pass.cpp b/test/containers/unord/unord.set/emplace_hint.pass.cpp index 59cf4455..de00ebee 100644 --- a/test/containers/unord/unord.set/emplace_hint.pass.cpp +++ b/test/containers/unord/unord.set/emplace_hint.pass.cpp @@ -20,6 +20,7 @@ #include #include "../../Emplaceable.h" +#include "../../min_allocator.h" int main() { @@ -41,5 +42,25 @@ int main() assert(c.size() == 2); assert(*r == Emplaceable(5, 6)); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef C::iterator R; + C c; + C::const_iterator e = c.end(); + R r = c.emplace_hint(e); + assert(c.size() == 1); + assert(*r == Emplaceable()); + + r = c.emplace_hint(e, Emplaceable(5, 6)); + assert(c.size() == 2); + assert(*r == Emplaceable(5, 6)); + + r = c.emplace_hint(r, 5, 6); + assert(c.size() == 2); + assert(*r == Emplaceable(5, 6)); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.set/eq.pass.cpp b/test/containers/unord/unord.set/eq.pass.cpp index 52d8304b..7b5569e2 100644 --- a/test/containers/unord/unord.set/eq.pass.cpp +++ b/test/containers/unord/unord.set/eq.pass.cpp @@ -22,6 +22,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -88,4 +90,70 @@ int main() assert( (c1 == c2)); assert(!(c1 != c2)); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + const C c1(std::begin(a), std::end(a)); + const C c2; + assert(!(c1 == c2)); + assert( (c1 != c2)); + } + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + const C c1(std::begin(a), std::end(a)); + const C c2 = c1; + assert( (c1 == c2)); + assert(!(c1 != c2)); + } + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + C c1(std::begin(a), std::end(a)); + C c2 = c1; + c2.rehash(30); + assert( (c1 == c2)); + assert(!(c1 != c2)); + c2.insert(P(90)); + assert(!(c1 == c2)); + assert( (c1 != c2)); + c1.insert(P(90)); + assert( (c1 == c2)); + assert(!(c1 != c2)); + } +#endif } diff --git a/test/containers/unord/unord.set/equal_range_const.pass.cpp b/test/containers/unord/unord.set/equal_range_const.pass.cpp index 98e4885c..c64e0af3 100644 --- a/test/containers/unord/unord.set/equal_range_const.pass.cpp +++ b/test/containers/unord/unord.set/equal_range_const.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -47,4 +49,33 @@ int main() assert(std::distance(r.first, r.second) == 1); assert(*r.first == 50); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef C::const_iterator I; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(50), + P(50), + P(60), + P(70), + P(80) + }; + const C c(std::begin(a), std::end(a)); + std::pair r = c.equal_range(30); + assert(std::distance(r.first, r.second) == 1); + assert(*r.first == 30); + r = c.equal_range(5); + assert(std::distance(r.first, r.second) == 0); + r = c.equal_range(50); + assert(std::distance(r.first, r.second) == 1); + assert(*r.first == 50); + } +#endif } diff --git a/test/containers/unord/unord.set/equal_range_non_const.pass.cpp b/test/containers/unord/unord.set/equal_range_non_const.pass.cpp index ba7ba0d1..6d7e044b 100644 --- a/test/containers/unord/unord.set/equal_range_non_const.pass.cpp +++ b/test/containers/unord/unord.set/equal_range_non_const.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -47,4 +49,33 @@ int main() assert(std::distance(r.first, r.second) == 1); assert(*r.first == 50); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef C::iterator I; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(50), + P(50), + P(60), + P(70), + P(80) + }; + C c(std::begin(a), std::end(a)); + std::pair r = c.equal_range(30); + assert(std::distance(r.first, r.second) == 1); + assert(*r.first == 30); + r = c.equal_range(5); + assert(std::distance(r.first, r.second) == 0); + r = c.equal_range(50); + assert(std::distance(r.first, r.second) == 1); + assert(*r.first == 50); + } +#endif } diff --git a/test/containers/unord/unord.set/erase_const_iter.pass.cpp b/test/containers/unord/unord.set/erase_const_iter.pass.cpp index a6038a4f..ff746016 100644 --- a/test/containers/unord/unord.set/erase_const_iter.pass.cpp +++ b/test/containers/unord/unord.set/erase_const_iter.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -40,4 +42,26 @@ int main() assert(c.count(3) == 1); assert(c.count(4) == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + C::const_iterator i = c.find(2); + C::iterator j = c.erase(i); + assert(c.size() == 3); + assert(c.count(1) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/erase_key.pass.cpp b/test/containers/unord/unord.set/erase_key.pass.cpp index c4483ec7..187f1182 100644 --- a/test/containers/unord/unord.set/erase_key.pass.cpp +++ b/test/containers/unord/unord.set/erase_key.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -77,4 +79,62 @@ int main() assert(c.erase(3) == 0); assert(c.size() == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.erase(5) == 0); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + + assert(c.erase(2) == 1); + assert(c.size() == 3); + assert(c.count(1) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + + assert(c.erase(2) == 0); + assert(c.size() == 3); + assert(c.count(1) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + + assert(c.erase(4) == 1); + assert(c.size() == 2); + assert(c.count(1) == 1); + assert(c.count(3) == 1); + + assert(c.erase(4) == 0); + assert(c.size() == 2); + assert(c.count(1) == 1); + assert(c.count(3) == 1); + + assert(c.erase(1) == 1); + assert(c.size() == 1); + assert(c.count(3) == 1); + + assert(c.erase(1) == 0); + assert(c.size() == 1); + assert(c.count(3) == 1); + + assert(c.erase(3) == 1); + assert(c.size() == 0); + + assert(c.erase(3) == 0); + assert(c.size() == 0); + } +#endif } diff --git a/test/containers/unord/unord.set/erase_range.pass.cpp b/test/containers/unord/unord.set/erase_range.pass.cpp index ba51efaf..98b7d4d4 100644 --- a/test/containers/unord/unord.set/erase_range.pass.cpp +++ b/test/containers/unord/unord.set/erase_range.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -53,4 +55,39 @@ int main() assert(c.size() == 0); assert(k == c.end()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + C::const_iterator i = c.find(2); + C::const_iterator j = next(i); + C::iterator k = c.erase(i, i); + assert(k == i); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + + k = c.erase(i, j); + assert(c.size() == 3); + assert(c.count(1) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + + k = c.erase(c.cbegin(), c.cend()); + assert(c.size() == 0); + assert(k == c.end()); + } +#endif } diff --git a/test/containers/unord/unord.set/find_const.pass.cpp b/test/containers/unord/unord.set/find_const.pass.cpp index 80dca545..ca8b9e6a 100644 --- a/test/containers/unord/unord.set/find_const.pass.cpp +++ b/test/containers/unord/unord.set/find_const.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -40,4 +42,26 @@ int main() i = c.find(5); assert(i == c.cend()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + const C c(std::begin(a), std::end(a)); + C::const_iterator i = c.find(30); + assert(*i == 30); + i = c.find(5); + assert(i == c.cend()); + } +#endif } diff --git a/test/containers/unord/unord.set/find_non_const.pass.cpp b/test/containers/unord/unord.set/find_non_const.pass.cpp index 8ff0fe4b..a2ab8042 100644 --- a/test/containers/unord/unord.set/find_non_const.pass.cpp +++ b/test/containers/unord/unord.set/find_non_const.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -40,4 +42,26 @@ int main() i = c.find(5); assert(i == c.cend()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + C c(std::begin(a), std::end(a)); + C::iterator i = c.find(30); + assert(*i == 30); + i = c.find(5); + assert(i == c.cend()); + } +#endif } diff --git a/test/containers/unord/unord.set/insert_const_lvalue.pass.cpp b/test/containers/unord/unord.set/insert_const_lvalue.pass.cpp index 36ee2cfb..b5d2733e 100644 --- a/test/containers/unord/unord.set/insert_const_lvalue.pass.cpp +++ b/test/containers/unord/unord.set/insert_const_lvalue.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -45,4 +47,32 @@ int main() assert(*r.first == 5.5); assert(r.second); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef std::pair R; + typedef C::value_type P; + C c; + R r = c.insert(P(3.5)); + assert(c.size() == 1); + assert(*r.first == 3.5); + assert(r.second); + + r = c.insert(P(3.5)); + assert(c.size() == 1); + assert(*r.first == 3.5); + assert(!r.second); + + r = c.insert(P(4.5)); + assert(c.size() == 2); + assert(*r.first == 4.5); + assert(r.second); + + r = c.insert(P(5.5)); + assert(c.size() == 3); + assert(*r.first == 5.5); + assert(r.second); + } +#endif } diff --git a/test/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp b/test/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp index 88b317aa..cbc212aa 100644 --- a/test/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp +++ b/test/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -42,4 +44,29 @@ int main() assert(c.size() == 3); assert(*r == 5.5); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef C::iterator R; + typedef C::value_type P; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, P(3.5)); + assert(c.size() == 1); + assert(*r == 3.5); + + r = c.insert(e, P(3.5)); + assert(c.size() == 1); + assert(*r == 3.5); + + r = c.insert(e, P(4.5)); + assert(c.size() == 2); + assert(*r == 4.5); + + r = c.insert(e, P(5.5)); + assert(c.size() == 3); + assert(*r == 5.5); + } +#endif } diff --git a/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp b/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp index 3d79fbcc..8d7e5ba7 100644 --- a/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp +++ b/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp @@ -19,6 +19,7 @@ #include #include "../../MoveOnly.h" +#include "../../min_allocator.h" int main() { @@ -68,4 +69,54 @@ int main() assert(*r == 5); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef C::iterator R; + typedef double P; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, P(3.5)); + assert(c.size() == 1); + assert(*r == 3.5); + + r = c.insert(r, P(3.5)); + assert(c.size() == 1); + assert(*r == 3.5); + + r = c.insert(e, P(4.5)); + assert(c.size() == 2); + assert(*r == 4.5); + + r = c.insert(e, P(5.5)); + assert(c.size() == 3); + assert(*r == 5.5); + } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef C::iterator R; + typedef MoveOnly P; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, P(3)); + assert(c.size() == 1); + assert(*r == 3); + + r = c.insert(r, P(3)); + assert(c.size() == 1); + assert(*r == 3); + + r = c.insert(e, P(4)); + assert(c.size() == 2); + assert(*r == 4); + + r = c.insert(e, P(5)); + assert(c.size() == 3); + assert(*r == 5); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/containers/unord/unord.set/insert_init.pass.cpp b/test/containers/unord/unord.set/insert_init.pass.cpp index 3b1abdf4..18a97a15 100644 --- a/test/containers/unord/unord.set/insert_init.pass.cpp +++ b/test/containers/unord/unord.set/insert_init.pass.cpp @@ -19,6 +19,7 @@ #include #include "test_iterators.h" +#include "../../min_allocator.h" int main() { @@ -43,5 +44,28 @@ int main() assert(c.count(3) == 1); assert(c.count(4) == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef int P; + C c; + c.insert( + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + } + ); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.set/insert_range.pass.cpp b/test/containers/unord/unord.set/insert_range.pass.cpp index b0b8fc62..aa3b38bb 100644 --- a/test/containers/unord/unord.set/insert_range.pass.cpp +++ b/test/containers/unord/unord.set/insert_range.pass.cpp @@ -20,6 +20,7 @@ #include #include "test_iterators.h" +#include "../../min_allocator.h" int main() { @@ -43,4 +44,27 @@ int main() assert(c.count(3) == 1); assert(c.count(4) == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c; + c.insert(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0]))); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/insert_rvalue.pass.cpp b/test/containers/unord/unord.set/insert_rvalue.pass.cpp index e3268f0a..9ed2cda9 100644 --- a/test/containers/unord/unord.set/insert_rvalue.pass.cpp +++ b/test/containers/unord/unord.set/insert_rvalue.pass.cpp @@ -19,6 +19,7 @@ #include #include "../../MoveOnly.h" +#include "../../min_allocator.h" int main() { @@ -74,4 +75,60 @@ int main() assert(r.second); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef std::pair R; + typedef double P; + C c; + R r = c.insert(P(3.5)); + assert(c.size() == 1); + assert(*r.first == 3.5); + assert(r.second); + + r = c.insert(P(3.5)); + assert(c.size() == 1); + assert(*r.first == 3.5); + assert(!r.second); + + r = c.insert(P(4.5)); + assert(c.size() == 2); + assert(*r.first == 4.5); + assert(r.second); + + r = c.insert(P(5.5)); + assert(c.size() == 3); + assert(*r.first == 5.5); + assert(r.second); + } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef std::pair R; + typedef MoveOnly P; + C c; + R r = c.insert(P(3)); + assert(c.size() == 1); + assert(*r.first == 3); + assert(r.second); + + r = c.insert(P(3)); + assert(c.size() == 1); + assert(*r.first == 3); + assert(!r.second); + + r = c.insert(P(4)); + assert(c.size() == 2); + assert(*r.first == 4); + assert(r.second); + + r = c.insert(P(5)); + assert(c.size() == 3); + assert(*r.first == 5); + assert(r.second); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/containers/unord/unord.set/iterators.pass.cpp b/test/containers/unord/unord.set/iterators.pass.cpp index ef1ecb9e..7815b9b3 100644 --- a/test/containers/unord/unord.set/iterators.pass.cpp +++ b/test/containers/unord/unord.set/iterators.pass.cpp @@ -23,6 +23,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -63,4 +65,46 @@ int main() assert(std::distance(c.cbegin(), c.cend()) == c.size()); C::const_iterator i; } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 5); + assert(c.size() == 4); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + C::iterator i; + } + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + const C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 5); + assert(c.size() == 4); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + C::const_iterator i; + } +#endif } diff --git a/test/containers/unord/unord.set/load_factor.pass.cpp b/test/containers/unord/unord.set/load_factor.pass.cpp index 60b0f91e..959f384c 100644 --- a/test/containers/unord/unord.set/load_factor.pass.cpp +++ b/test/containers/unord/unord.set/load_factor.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -44,4 +46,31 @@ int main() const C c; assert(c.load_factor() == 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + const C c(std::begin(a), std::end(a)); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + } + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef int P; + const C c; + assert(c.load_factor() == 0); + } +#endif } diff --git a/test/containers/unord/unord.set/local_iterators.pass.cpp b/test/containers/unord/unord.set/local_iterators.pass.cpp index 93d7ea89..5b82228a 100644 --- a/test/containers/unord/unord.set/local_iterators.pass.cpp +++ b/test/containers/unord/unord.set/local_iterators.pass.cpp @@ -23,6 +23,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -201,4 +203,186 @@ int main() assert(std::distance(i, j) == 1); assert(*i == 4); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef int P; + typedef C::local_iterator I; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 5); + C::size_type b = c.bucket(0); + I i = c.begin(b); + I j = c.end(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(*i == 1); + + b = c.bucket(2); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(*i == 2); + + b = c.bucket(3); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(*i == 3); + + b = c.bucket(4); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(*i == 4); + } + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef int P; + typedef C::const_local_iterator I; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + const C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 5); + C::size_type b = c.bucket(0); + I i = c.begin(b); + I j = c.end(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(*i == 1); + + b = c.bucket(2); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(*i == 2); + + b = c.bucket(3); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(*i == 3); + + b = c.bucket(4); + i = c.begin(b); + j = c.end(b); + assert(std::distance(i, j) == 1); + assert(*i == 4); + } + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef int P; + typedef C::const_local_iterator I; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 5); + C::size_type b = c.bucket(0); + I i = c.cbegin(b); + I j = c.cend(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(*i == 1); + + b = c.bucket(2); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(*i == 2); + + b = c.bucket(3); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(*i == 3); + + b = c.bucket(4); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(*i == 4); + } + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef int P; + typedef C::const_local_iterator I; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + const C c(a, a + sizeof(a)/sizeof(a[0])); + assert(c.bucket_count() >= 5); + C::size_type b = c.bucket(0); + I i = c.cbegin(b); + I j = c.cend(b); + assert(std::distance(i, j) == 0); + + b = c.bucket(1); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(*i == 1); + + b = c.bucket(2); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(*i == 2); + + b = c.bucket(3); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(*i == 3); + + b = c.bucket(4); + i = c.cbegin(b); + j = c.cend(b); + assert(std::distance(i, j) == 1); + assert(*i == 4); + } +#endif } diff --git a/test/containers/unord/unord.set/max_bucket_count.pass.cpp b/test/containers/unord/unord.set/max_bucket_count.pass.cpp index ee36c569..80398b8f 100644 --- a/test/containers/unord/unord.set/max_bucket_count.pass.cpp +++ b/test/containers/unord/unord.set/max_bucket_count.pass.cpp @@ -18,6 +18,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -25,4 +27,12 @@ int main() const C c; assert(c.max_bucket_count() > 0); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + const C c; + assert(c.max_bucket_count() > 0); + } +#endif } diff --git a/test/containers/unord/unord.set/max_load_factor.pass.cpp b/test/containers/unord/unord.set/max_load_factor.pass.cpp index 66470373..db7e7843 100644 --- a/test/containers/unord/unord.set/max_load_factor.pass.cpp +++ b/test/containers/unord/unord.set/max_load_factor.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -35,4 +37,22 @@ int main() c.max_load_factor(2.5); assert(c.max_load_factor() == 2.5); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef int P; + const C c; + assert(c.max_load_factor() == 1); + } + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef int P; + C c; + assert(c.max_load_factor() == 1); + c.max_load_factor(2.5); + assert(c.max_load_factor() == 2.5); + } +#endif } diff --git a/test/containers/unord/unord.set/max_size.pass.cpp b/test/containers/unord/unord.set/max_size.pass.cpp index 2c5d3be8..43d66bb6 100644 --- a/test/containers/unord/unord.set/max_size.pass.cpp +++ b/test/containers/unord/unord.set/max_size.pass.cpp @@ -18,10 +18,19 @@ #include #include +#include "../../min_allocator.h" + int main() { { std::unordered_set u; assert(u.max_size() > 0); } +#if __cplusplus >= 201103L + { + std::unordered_set, + std::equal_to, min_allocator> u; + assert(u.max_size() > 0); + } +#endif } diff --git a/test/containers/unord/unord.set/rehash.pass.cpp b/test/containers/unord/unord.set/rehash.pass.cpp index ae962c99..bf4d3175 100644 --- a/test/containers/unord/unord.set/rehash.pass.cpp +++ b/test/containers/unord/unord.set/rehash.pass.cpp @@ -18,7 +18,10 @@ #include #include -void test(const std::unordered_set& c) +#include "../../min_allocator.h" + +template +void test(const C& c) { assert(c.size() == 4); assert(c.count(1) == 1); @@ -55,4 +58,33 @@ int main() assert(c.bucket_count() == 31); test(c); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + test(c); + assert(c.bucket_count() >= 5); + c.rehash(3); + assert(c.bucket_count() == 5); + test(c); + c.max_load_factor(2); + c.rehash(3); + assert(c.bucket_count() == 3); + test(c); + c.rehash(31); + assert(c.bucket_count() == 31); + test(c); + } +#endif } diff --git a/test/containers/unord/unord.set/reserve.pass.cpp b/test/containers/unord/unord.set/reserve.pass.cpp index 79507743..525f9438 100644 --- a/test/containers/unord/unord.set/reserve.pass.cpp +++ b/test/containers/unord/unord.set/reserve.pass.cpp @@ -18,7 +18,10 @@ #include #include -void test(const std::unordered_set& c) +#include "../../min_allocator.h" + +template +void test(const C& c) { assert(c.size() == 4); assert(c.count(1) == 1); @@ -55,4 +58,33 @@ int main() assert(c.bucket_count() >= 16); test(c); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + test(c); + assert(c.bucket_count() >= 5); + c.reserve(3); + assert(c.bucket_count() == 5); + test(c); + c.max_load_factor(2); + c.reserve(3); + assert(c.bucket_count() >= 2); + test(c); + c.reserve(31); + assert(c.bucket_count() >= 16); + test(c); + } +#endif } diff --git a/test/containers/unord/unord.set/swap_member.pass.cpp b/test/containers/unord/unord.set/swap_member.pass.cpp index 3d903626..9a972b72 100644 --- a/test/containers/unord/unord.set/swap_member.pass.cpp +++ b/test/containers/unord/unord.set/swap_member.pass.cpp @@ -21,6 +21,7 @@ #include "../../test_compare.h" #include "../../test_hash.h" #include "../../test_allocator.h" +#include "../../min_allocator.h" int main() { @@ -385,4 +386,186 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set C; + typedef int P; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set C; + typedef int P; + P a2[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(*c1.find(10) == 10); + assert(*c1.find(20) == 20); + assert(*c1.find(30) == 30); + assert(*c1.find(40) == 40); + assert(*c1.find(50) == 50); + assert(*c1.find(60) == 60); + assert(*c1.find(70) == 70); + assert(*c1.find(80) == 80); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set C; + typedef int P; + P a1[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 5); + assert(c2.size() == 4); + assert(c2.count(1) == 1); + assert(c2.count(2) == 1); + assert(c2.count(3) == 1); + assert(c2.count(4) == 1); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set C; + typedef int P; + P a1[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + P a2[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + c1.swap(c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(*c1.find(10) == 10); + assert(*c1.find(20) == 20); + assert(*c1.find(30) == 30); + assert(*c1.find(40) == 40); + assert(*c1.find(50) == 50); + assert(*c1.find(60) == 60); + assert(*c1.find(70) == 70); + assert(*c1.find(80) == 80); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 5); + assert(c2.size() == 4); + assert(c2.count(1) == 1); + assert(c2.count(2) == 1); + assert(c2.count(3) == 1); + assert(c2.count(4) == 1); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/types.pass.cpp b/test/containers/unord/unord.set/types.pass.cpp index a69eb0a0..11d992f9 100644 --- a/test/containers/unord/unord.set/types.pass.cpp +++ b/test/containers/unord/unord.set/types.pass.cpp @@ -30,6 +30,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -46,4 +48,21 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp index a5e2368d..31878362 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -42,4 +43,23 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + C c(min_allocator{}); + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp index eaf2e803..e7fa9036 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -115,4 +116,51 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef min_allocator A; + typedef std::unordered_set >, + test_compare >, + A + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(3), + A() + ); + c = c0; + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == A()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp index 10fff26c..256f4447 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -58,5 +59,39 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef min_allocator A; + typedef std::unordered_set >, + test_compare >, + A + > C; + typedef int P; + C c = { + P(4), + P(1), + P(2) + }; + c = { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + assert(c.bucket_count() >= 5); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp index 945c8ef8..8dab47b8 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -161,5 +162,52 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef min_allocator A; + typedef std::unordered_set >, + test_compare >, + A + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(3), + A() + ); + c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == A()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp index d1ee1fb7..7fe0e15d 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -103,4 +104,44 @@ int main() assert(c.max_load_factor() == 1); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + C c = c0; + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp index 23924f07..67995b3a 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -63,4 +64,44 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + C c(c0, min_allocator()); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp index 2e73140a..e53264fc 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -42,4 +43,23 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + C c; + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (min_allocator())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp index 0d3320e3..8dc37e30 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -56,5 +57,37 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + typedef int P; + C c = { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + assert(c.bucket_count() >= 5); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp index 3ec3bbe9..3cc3cf0a 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -58,5 +59,39 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7 + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp index f953c1ef..9dc61fbb 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -60,5 +61,40 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp index 3b982510..a191c7c2 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -61,5 +62,41 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp index 2dc76902..4a1fc6cd 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp @@ -23,6 +23,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -62,5 +63,42 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp index 7077690f..5c75a3e8 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -101,5 +102,82 @@ int main() assert(c0.empty()); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 0); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + + assert(c0.empty()); + } + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + + assert(c0.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp index 0b1336a8..1e58dbd7 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -108,5 +109,48 @@ int main() assert(c0.empty()); } +#if __cplusplus >= 201103L + { + typedef int P; + typedef min_allocator A; + typedef std::unordered_set >, + test_compare >, + A + > C; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(a, a + sizeof(a)/sizeof(a[0]), + 7, + test_hash >(8), + test_compare >(9), + A() + ); + C c(std::move(c0), A()); + assert(c.bucket_count() >= 5); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == A()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + + assert(c0.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp index 1515a0c2..322fa3ff 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp @@ -24,6 +24,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -59,4 +60,38 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0]))); + assert(c.bucket_count() >= 5); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp index 33d8f3a1..87e62a00 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp @@ -24,6 +24,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -61,4 +62,40 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7 + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp index deabebdb..6f6f1782 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp @@ -25,6 +25,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -63,4 +64,41 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp index a0fafadd..ac2aafd7 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp @@ -25,6 +25,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -64,4 +65,42 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp index c6153df6..5a051e82 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp @@ -26,6 +26,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -66,4 +67,43 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + assert(c.bucket_count() == 7); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp index b5d970d2..fe019669 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -42,4 +43,23 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + C c(7); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (min_allocator())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp index 575236f0..2bda6cc2 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -44,4 +45,25 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + C c(7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (min_allocator())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp index 380082cd..bd5e7545 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -45,4 +46,26 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + C c(7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == (min_allocator())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp index b5666878..e3378ce8 100644 --- a/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp @@ -22,6 +22,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -34,7 +35,7 @@ int main() C c(7, test_hash >(8), test_compare >(9), - test_allocator >(10) + test_allocator(10) ); assert(c.bucket_count() == 7); assert(c.hash_function() == test_hash >(8)); @@ -46,4 +47,27 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef std::unordered_set >, + test_compare >, + min_allocator + > C; + C c(7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == (min_allocator())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif } diff --git a/test/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp b/test/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp index ffe102d2..57899aef 100644 --- a/test/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp +++ b/test/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp @@ -21,6 +21,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -385,4 +386,186 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } +#if __cplusplus >= 201103L + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set C; + typedef int P; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set C; + typedef int P; + P a2[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + C c1(0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(*c1.find(10) == 10); + assert(*c1.find(20) == 20); + assert(*c1.find(30) == 30); + assert(*c1.find(40) == 40); + assert(*c1.find(50) == 50); + assert(*c1.find(60) == 60); + assert(*c1.find(70) == 70); + assert(*c1.find(80) == 80); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() == 0); + assert(c2.size() == 0); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set C; + typedef int P; + P a1[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() == 0); + assert(c1.size() == 0); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 5); + assert(c2.size() == 4); + assert(c2.count(1) == 1); + assert(c2.count(2) == 1); + assert(c2.count(3) == 1); + assert(c2.count(4) == 1); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set C; + typedef int P; + P a1[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + P a2[] = + { + P(10), + P(20), + P(30), + P(40), + P(50), + P(60), + P(70), + P(80) + }; + C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc()); + C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc()); + c2.max_load_factor(2); + swap(c1, c2); + + assert(c1.bucket_count() >= 11); + assert(c1.size() == 8); + assert(*c1.find(10) == 10); + assert(*c1.find(20) == 20); + assert(*c1.find(30) == 30); + assert(*c1.find(40) == 40); + assert(*c1.find(50) == 50); + assert(*c1.find(60) == 60); + assert(*c1.find(70) == 70); + assert(*c1.find(80) == 80); + assert(c1.hash_function() == Hash(2)); + assert(c1.key_eq() == Compare(2)); + assert(c1.get_allocator() == Alloc()); + assert(std::distance(c1.begin(), c1.end()) == c1.size()); + assert(std::distance(c1.cbegin(), c1.cend()) == c1.size()); + assert(c1.max_load_factor() == 2); + + assert(c2.bucket_count() >= 5); + assert(c2.size() == 4); + assert(c2.count(1) == 1); + assert(c2.count(2) == 1); + assert(c2.count(3) == 1); + assert(c2.count(4) == 1); + assert(c2.hash_function() == Hash(1)); + assert(c2.key_eq() == Compare(1)); + assert(c2.get_allocator() == Alloc()); + assert(std::distance(c2.begin(), c2.end()) == c2.size()); + assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); + assert(c2.max_load_factor() == 1); + } +#endif } diff --git a/test/testit b/test/testit index f137745d..a7423645 100755 --- a/test/testit +++ b/test/testit @@ -38,7 +38,7 @@ fi if [ -z "$OPTIONS" ] then - OPTIONS="-std=c++0x -stdlib=libc++" + OPTIONS="-std=c++11 -stdlib=libc++" fi OPTIONS="$OPTIONS -I$LIBCXX_ROOT/test/support"