diff --git a/libcxx/include/__tree b/libcxx/include/__tree index cd6d7efaae84..9ffc38d2287e 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -644,7 +644,8 @@ public: _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;} - _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &__ptr_->__value_;} + _LIBCPP_INLINE_VISIBILITY pointer operator->() const + {return pointer_traits::pointer_to(__ptr_->__value_);} _LIBCPP_INLINE_VISIBILITY __tree_iterator& operator++() @@ -686,7 +687,7 @@ class _LIBCPP_TYPE_VIS __tree_const_iterator { typedef _ConstNodePtr __node_pointer; typedef typename pointer_traits<__node_pointer>::element_type __node; - typedef const typename __node::base __node_base; + typedef typename __node::base __node_base; typedef typename pointer_traits<__node_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind<__node_base> @@ -729,7 +730,8 @@ public: : __ptr_(__p.__ptr_) {} _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;} - _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &__ptr_->__value_;} + _LIBCPP_INLINE_VISIBILITY pointer operator->() const + {return pointer_traits::pointer_to(__ptr_->__value_);} _LIBCPP_INLINE_VISIBILITY __tree_const_iterator& operator++() @@ -779,8 +781,10 @@ public: typedef typename __alloc_traits::size_type size_type; typedef typename __alloc_traits::difference_type difference_type; - typedef __tree_node __node; - typedef __tree_node_base __node_base; + typedef typename __alloc_traits::void_pointer __void_pointer; + + typedef __tree_node __node; + typedef __tree_node_base<__void_pointer> __node_base; typedef typename __alloc_traits::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind_alloc<__node> @@ -790,9 +794,9 @@ 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 typename __node_base::pointer __node_base_pointer; - typedef typename __node_base::const_pointer __node_base_const_pointer; + typedef typename __node_base::pointer __node_base_const_pointer; private: typedef typename __node_base::base __end_node_t; typedef typename pointer_traits<__node_pointer>::template @@ -804,9 +808,9 @@ private: __end_node_ptr; typedef typename pointer_traits<__node_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind + rebind<__end_node_t> #else - rebind::other + rebind<__end_node_t>::other #endif __end_node_const_ptr; @@ -828,7 +832,7 @@ public: { return static_cast<__node_const_pointer> ( - pointer_traits<__end_node_const_ptr>::pointer_to(__pair1_.first()) + pointer_traits<__end_node_const_ptr>::pointer_to(const_cast<__end_node_t&>(__pair1_.first())) ); } _LIBCPP_INLINE_VISIBILITY @@ -865,7 +869,7 @@ public: {return static_cast<__node_const_pointer>(__end_node()->__left_);} typedef __tree_iterator iterator; - typedef __tree_const_iterator const_iterator; + typedef __tree_const_iterator const_iterator; explicit __tree(const value_compare& __comp) _NOEXCEPT_( @@ -1102,6 +1106,9 @@ private: __node_pointer __detach(); static __node_pointer __detach(__node_pointer); + + template friend class _LIBCPP_TYPE_VIS map; + template friend class _LIBCPP_TYPE_VIS multimap; }; template @@ -1161,7 +1168,7 @@ __tree<_Tp, _Compare, _Allocator>::__detach(__node_pointer __cache) { if (__cache->__parent_ == nullptr) return nullptr; - if (__tree_is_left_child(__cache)) + if (__tree_is_left_child(static_cast<__node_base_pointer>(__cache))) { __cache->__parent_->__left_ = nullptr; __cache = static_cast<__node_pointer>(__cache->__parent_); @@ -1294,7 +1301,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) __begin_node() = __end_node(); else { - __end_node()->__left_->__parent_ = __end_node(); + __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node()); __t.__begin_node() = __t.__end_node(); __t.__end_node()->__left_ = nullptr; __t.size() = 0; @@ -1314,7 +1321,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __ { __begin_node() = __t.__begin_node(); __end_node()->__left_ = __t.__end_node()->__left_; - __end_node()->__left_->__parent_ = __end_node(); + __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node()); size() = __t.size(); __t.__begin_node() = __t.__end_node(); __t.__end_node()->__left_ = nullptr; @@ -1342,7 +1349,7 @@ __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type) __begin_node() = __end_node(); else { - __end_node()->__left_->__parent_ = __end_node(); + __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node()); __t.__begin_node() = __t.__end_node(); __t.__end_node()->__left_ = nullptr; __t.size() = 0; @@ -1447,11 +1454,11 @@ __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) if (size() == 0) __begin_node() = __end_node(); else - __end_node()->__left_->__parent_ = __end_node(); + __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node()); if (__t.size() == 0) __t.__begin_node() = __t.__end_node(); else - __t.__end_node()->__left_->__parent_ = __t.__end_node(); + __t.__end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__t.__end_node()); } template @@ -1483,7 +1490,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(typename __node_base::pointer __nd = static_cast<__node_pointer>(__nd->__right_); else { - __parent = __nd; + __parent = static_cast<__node_base_pointer>(__nd); return __parent->__right_; } } @@ -1493,13 +1500,13 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(typename __node_base::pointer __nd = static_cast<__node_pointer>(__nd->__left_); else { - __parent = __nd; + __parent = static_cast<__node_base_pointer>(__nd); return __parent->__left_; } } } } - __parent = __end_node(); + __parent = static_cast<__node_base_pointer>(__end_node()); return __parent->__left_; } @@ -1522,7 +1529,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(typename __node_base::pointe __nd = static_cast<__node_pointer>(__nd->__left_); else { - __parent = __nd; + __parent = static_cast<__node_base_pointer>(__nd); return __parent->__left_; } } @@ -1532,13 +1539,13 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(typename __node_base::pointe __nd = static_cast<__node_pointer>(__nd->__right_); else { - __parent = __nd; + __parent = static_cast<__node_base_pointer>(__nd); return __parent->__right_; } } } } - __parent = __end_node(); + __parent = static_cast<__node_base_pointer>(__end_node()); return __parent->__left_; } @@ -1563,12 +1570,12 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, // *prev(__hint) <= __v <= *__hint if (__hint.__ptr_->__left_ == nullptr) { - __parent = const_cast<__node_pointer&>(__hint.__ptr_); + __parent = static_cast<__node_base_pointer>(__hint.__ptr_); return __parent->__left_; } else { - __parent = const_cast<__node_pointer&>(__prior.__ptr_); + __parent = static_cast<__node_base_pointer>(__prior.__ptr_); return __parent->__right_; } } @@ -1600,7 +1607,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(typename __node_base::pointer& _ __nd = static_cast<__node_pointer>(__nd->__left_); else { - __parent = __nd; + __parent = static_cast<__node_base_pointer>(__nd); return __parent->__left_; } } @@ -1610,18 +1617,18 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(typename __node_base::pointer& _ __nd = static_cast<__node_pointer>(__nd->__right_); else { - __parent = __nd; + __parent = static_cast<__node_base_pointer>(__nd); return __parent->__right_; } } else { - __parent = __nd; + __parent = static_cast<__node_base_pointer>(__nd); return __parent; } } } - __parent = __end_node(); + __parent = static_cast<__node_base_pointer>(__end_node()); return __parent->__left_; } @@ -1648,12 +1655,12 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, // *prev(__hint) < __v < *__hint if (__hint.__ptr_->__left_ == nullptr) { - __parent = const_cast<__node_pointer&>(__hint.__ptr_); + __parent = static_cast<__node_base_pointer>(__hint.__ptr_); return __parent->__left_; } else { - __parent = const_cast<__node_pointer&>(__prior.__ptr_); + __parent = static_cast<__node_base_pointer>(__prior.__ptr_); return __parent->__right_; } } @@ -1669,12 +1676,12 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, // *__hint < __v < *_VSTD::next(__hint) if (__hint.__ptr_->__right_ == nullptr) { - __parent = const_cast<__node_pointer&>(__hint.__ptr_); + __parent = static_cast<__node_base_pointer>(__hint.__ptr_); return __parent->__right_; } else { - __parent = const_cast<__node_pointer&>(__next.__ptr_); + __parent = static_cast<__node_base_pointer>(__next.__ptr_); return __parent->__left_; } } @@ -1682,7 +1689,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, return __find_equal(__parent, __v); } // else __v == *__hint - __parent = const_cast<__node_pointer&>(__hint.__ptr_); + __parent = static_cast<__node_base_pointer>(__hint.__ptr_); return __parent; } @@ -1729,7 +1736,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_unique(_Args&&... __args) bool __inserted = false; if (__child == nullptr) { - __insert_node_at(__parent, __child, __h.get()); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); __r = __h.release(); __inserted = true; } @@ -1747,7 +1754,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique(const_iterator __p, _Ar __node_pointer __r = static_cast<__node_pointer>(__child); if (__child == nullptr) { - __insert_node_at(__parent, __child, __h.get()); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); __r = __h.release(); } return iterator(__r); @@ -1761,7 +1768,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf_high(__parent, __h->__value_); - __insert_node_at(__parent, __child, __h.get()); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); return iterator(static_cast<__node_pointer>(__h.release())); } @@ -1774,7 +1781,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf(__p, __parent, __h->__value_); - __insert_node_at(__parent, __child, __h.get()); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); return iterator(static_cast<__node_pointer>(__h.release())); } @@ -1812,7 +1819,7 @@ __tree<_Tp, _Compare, _Allocator>::__insert_multi(_Vp&& __v) __node_holder __h = __construct_node(_VSTD::forward<_Vp>(__v)); __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf_high(__parent, __h->__value_); - __insert_node_at(__parent, __child, __h.get()); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); return iterator(__h.release()); } @@ -1824,7 +1831,7 @@ __tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, _Vp&& __v) __node_holder __h = __construct_node(_VSTD::forward<_Vp>(__v)); __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf(__p, __parent, __h->__value_); - __insert_node_at(__parent, __child, __h.get()); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); return iterator(__h.release()); } @@ -1854,7 +1861,7 @@ __tree<_Tp, _Compare, _Allocator>::__insert_unique(const value_type& __v) if (__child == nullptr) { __node_holder __h = __construct_node(__v); - __insert_node_at(__parent, __child, __h.get()); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); __r = __h.release(); __inserted = true; } @@ -1871,7 +1878,7 @@ __tree<_Tp, _Compare, _Allocator>::__insert_unique(const_iterator __p, const val if (__child == nullptr) { __node_holder __h = __construct_node(__v); - __insert_node_at(__parent, __child, __h.get()); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); __r = __h.release(); } return iterator(__r); @@ -1884,7 +1891,7 @@ __tree<_Tp, _Compare, _Allocator>::__insert_multi(const value_type& __v) __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf_high(__parent, __v); __node_holder __h = __construct_node(__v); - __insert_node_at(__parent, __child, __h.get()); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); return iterator(__h.release()); } @@ -1895,7 +1902,7 @@ __tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, const valu __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf(__p, __parent, __v); __node_holder __h = __construct_node(__v); - __insert_node_at(__parent, __child, __h.get()); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); return iterator(__h.release()); } @@ -1909,7 +1916,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_unique(__node_pointer __nd) bool __inserted = false; if (__child == nullptr) { - __insert_node_at(__parent, __child, __nd); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); __r = __nd; __inserted = true; } @@ -1926,7 +1933,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_unique(const_iterator __p, __node_pointer __r = static_cast<__node_pointer>(__child); if (__child == nullptr) { - __insert_node_at(__parent, __child, __nd); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); __r = __nd; } return iterator(__r); @@ -1938,7 +1945,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) { __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf_high(__parent, __nd->__value_); - __insert_node_at(__parent, __child, __nd); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); return iterator(__nd); } @@ -1949,7 +1956,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p, { __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf(__p, __parent, __nd->__value_); - __insert_node_at(__parent, __child, __nd); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); return iterator(__nd); } @@ -1957,7 +1964,7 @@ template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p) { - __node_pointer __np = const_cast<__node_pointer>(__p.__ptr_); + __node_pointer __np = __p.__ptr_; iterator __r(__np); ++__r; if (__begin_node() == __np) @@ -1977,7 +1984,7 @@ __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __f, const_iterator __l) { while (__f != __l) __f = erase(__f); - return iterator(const_cast<__node_pointer>(__l.__ptr_)); + return iterator(__l.__ptr_); } template @@ -2264,7 +2271,7 @@ template typename __tree<_Tp, _Compare, _Allocator>::__node_holder __tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT { - __node_pointer __np = const_cast<__node_pointer>(__p.__ptr_); + __node_pointer __np = __p.__ptr_; if (__begin_node() == __np) { if (__np->__right_ != nullptr) diff --git a/libcxx/include/map b/libcxx/include/map index abc07a35d0ea..df174daaae38 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -489,8 +489,8 @@ class __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_; @@ -522,9 +522,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); } @@ -542,8 +542,8 @@ class _LIBCPP_TYPE_VIS __map_iterator _TreeIterator __i_; typedef typename _TreeIterator::__pointer_traits __pointer_traits; - typedef const typename _TreeIterator::value_type::first_type __key_type; - typedef typename _TreeIterator::value_type::second_type __mapped_type; + typedef const typename _TreeIterator::value_type::value_type::first_type __key_type; + typedef typename _TreeIterator::value_type::value_type::second_type __mapped_type; public: typedef bidirectional_iterator_tag iterator_category; typedef pair<__key_type, __mapped_type> value_type; @@ -564,9 +564,9 @@ public: __map_iterator(_TreeIterator __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 __map_iterator& operator++() {++__i_; return *this;} @@ -607,8 +607,8 @@ class _LIBCPP_TYPE_VIS __map_const_iterator _TreeIterator __i_; typedef typename _TreeIterator::__pointer_traits __pointer_traits; - typedef const typename _TreeIterator::value_type::first_type __key_type; - typedef typename _TreeIterator::value_type::second_type __mapped_type; + typedef const typename _TreeIterator::value_type::value_type::first_type __key_type; + typedef typename _TreeIterator::value_type::value_type::second_type __mapped_type; public: typedef bidirectional_iterator_tag iterator_category; typedef pair<__key_type, __mapped_type> value_type; @@ -634,9 +634,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 __map_const_iterator& operator++() {++__i_; return *this;} @@ -679,6 +679,7 @@ public: typedef _Key key_type; typedef _Tp mapped_type; typedef pair value_type; + typedef pair __nc_value_type; typedef _Compare key_compare; typedef _Allocator allocator_type; typedef value_type& reference; @@ -699,7 +700,54 @@ public: }; private: - typedef pair __value_type; + +#if __cplusplus >= 201103L + union __value_type + { + typedef typename map::value_type value_type; + typedef typename 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 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 __map_value_compare __vc; typedef typename allocator_traits::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -764,7 +812,14 @@ public: _LIBCPP_INLINE_VISIBILITY map& operator=(const map& __m) { +#if __cplusplus >= 201103L __tree_ = __m.__tree_; +#else + __tree_.clear(); + __tree_.value_comp() = __m.__tree_.value_comp(); + __tree_.__copy_assign_alloc(__m.__tree_); + insert(__m.begin(), __m.end()); +#endif return *this; } @@ -1009,9 +1064,6 @@ private: __node_base_pointer& __find_equal_key(__node_base_pointer& __parent, const key_type& __k); - __node_base_pointer& - __find_equal_key(const_iterator __hint, - __node_base_pointer& __parent, const key_type& __k); __node_base_const_pointer __find_equal_key(__node_base_const_pointer& __parent, const key_type& __k) const; }; @@ -1030,97 +1082,37 @@ map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_pointer& __pa { while (true) { - if (__tree_.value_comp().key_comp()(__k, __nd->__value_.first)) + if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first)) { if (__nd->__left_ != nullptr) __nd = static_cast<__node_pointer>(__nd->__left_); else { - __parent = __nd; + __parent = static_cast<__node_base_pointer>(__nd); return __parent->__left_; } } - else if (__tree_.value_comp().key_comp()(__nd->__value_.first, __k)) + else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k)) { if (__nd->__right_ != nullptr) __nd = static_cast<__node_pointer>(__nd->__right_); else { - __parent = __nd; + __parent = static_cast<__node_base_pointer>(__nd); return __parent->__right_; } } else { - __parent = __nd; + __parent = static_cast<__node_base_pointer>(__nd); return __parent; } } } - __parent = __tree_.__end_node(); + __parent = static_cast<__node_base_pointer>(__tree_.__end_node()); return __parent->__left_; } -// Find place to insert if __k doesn't exist -// First check prior to __hint. -// Next check after __hint. -// Next do O(log N) search. -// Set __parent to parent of null leaf -// Return reference to null leaf -// If __k exists, set parent to node of __k and return reference to node of __k -template -typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_pointer& -map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(const_iterator __hint, - __node_base_pointer& __parent, - const key_type& __k) -{ - if (__hint == end() || __tree_.value_comp().key_comp()(__k, __hint->first)) // check before - { - // __k < *__hint - const_iterator __prior = __hint; - if (__prior == begin() || __tree_.value_comp().key_comp()((--__prior)->first, __k)) - { - // *prev(__hint) < __k < *__hint - if (__hint.__ptr_->__left_ == nullptr) - { - __parent = const_cast<__node_pointer&>(__hint.__ptr_); - return __parent->__left_; - } - else - { - __parent = const_cast<__node_pointer&>(__prior.__ptr_); - return __parent->__right_; - } - } - // __k <= *prev(__hint) - return __find_equal_key(__parent, __k); - } - else if (__tree_.value_comp().key_comp()(__hint->first, __k)) // check after - { - // *__hint < __k - const_iterator __next = _VSTD::next(__hint); - if (__next == end() || __tree_.value_comp().key_comp()(__k, __next->first)) - { - // *__hint < __k < *next(__hint) - if (__hint.__ptr_->__right_ == nullptr) - { - __parent = const_cast<__node_pointer&>(__hint.__ptr_); - return __parent->__right_; - } - else - { - __parent = const_cast<__node_pointer&>(__next.__ptr_); - return __parent->__left_; - } - } - // *next(__hint) <= __k - return __find_equal_key(__parent, __k); - } - // else __k == *__hint - __parent = const_cast<__node_pointer&>(__hint.__ptr_); - return __parent; -} - // Find __k // Set __parent to parent of null leaf and // return reference to null leaf iv __k does not exist. @@ -1135,34 +1127,34 @@ map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_const_pointer { while (true) { - if (__tree_.value_comp().key_comp()(__k, __nd->__value_.first)) + if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first)) { if (__nd->__left_ != nullptr) __nd = static_cast<__node_pointer>(__nd->__left_); else { - __parent = __nd; + __parent = static_cast<__node_base_pointer>(__nd); return const_cast(__parent->__left_); } } - else if (__tree_.value_comp().key_comp()(__nd->__value_.first, __k)) + else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k)) { if (__nd->__right_ != nullptr) __nd = static_cast<__node_pointer>(__nd->__right_); else { - __parent = __nd; + __parent = static_cast<__node_base_pointer>(__nd); return const_cast(__parent->__right_); } } else { - __parent = __nd; + __parent = static_cast<__node_base_pointer>(__nd); return __parent; } } } - __parent = __tree_.__end_node(); + __parent = static_cast<__node_base_pointer>(__tree_.__end_node()); return const_cast(__parent->__left_); } @@ -1187,9 +1179,9 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node() { __node_allocator& __na = __tree_.__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)); __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; } @@ -1222,9 +1214,9 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0) { __node_allocator& __na = __tree_.__node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), _VSTD::forward<_A0>(__a0)); + __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; } @@ -1256,9 +1248,9 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node(const key_type& __k) { __node_allocator& __na = __tree_.__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); } @@ -1275,10 +1267,10 @@ map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) if (__child == nullptr) { __node_holder __h = __construct_node(__k); - __tree_.__insert_node_at(__parent, __child, __h.get()); + __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); __r = __h.release(); } - return __r->__value_.second; + return __r->__value_.__cc.second; } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1293,10 +1285,10 @@ map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) if (__child == nullptr) { __node_holder __h = __construct_node(_VSTD::move(__k)); - __tree_.__insert_node_at(__parent, __child, __h.get()); + __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); __r = __h.release(); } - return __r->__value_.second; + return __r->__value_.__cc.second; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1311,7 +1303,7 @@ map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) if (__child == nullptr) throw out_of_range("map::at: key not found"); #endif // _LIBCPP_NO_EXCEPTIONS - return static_cast<__node_pointer>(__child)->__value_.second; + return static_cast<__node_pointer>(__child)->__value_.__cc.second; } template @@ -1324,7 +1316,7 @@ map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const if (__child == nullptr) throw out_of_range("map::at: key not found"); #endif // _LIBCPP_NO_EXCEPTIONS - return static_cast<__node_const_pointer>(__child)->__value_.second; + return static_cast<__node_const_pointer>(__child)->__value_.__cc.second; } #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) @@ -1429,6 +1421,7 @@ public: typedef _Key key_type; typedef _Tp mapped_type; typedef pair value_type; + typedef pair __nc_value_type; typedef _Compare key_compare; typedef _Allocator allocator_type; typedef value_type& reference; @@ -1450,7 +1443,53 @@ public: }; private: - typedef pair __value_type; +#if __cplusplus >= 201103L + union __value_type + { + typedef typename multimap::value_type value_type; + typedef typename 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 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 __map_value_compare __vc; typedef typename allocator_traits::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -1516,7 +1555,14 @@ public: _LIBCPP_INLINE_VISIBILITY multimap& operator=(const multimap& __m) { +#if __cplusplus >= 201103L __tree_ = __m.__tree_; +#else + __tree_.clear(); + __tree_.value_comp() = __m.__tree_.value_comp(); + __tree_.__copy_assign_alloc(__m.__tree_); + insert(__m.begin(), __m.end()); +#endif return *this; } @@ -1766,9 +1812,9 @@ multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node() { __node_allocator& __na = __tree_.__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)); __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; } @@ -1801,9 +1847,9 @@ multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0) { __node_allocator& __na = __tree_.__node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), _VSTD::forward<_A0>(__a0)); + __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/libcxx/test/containers/associative/map/map.access/at.pass.cpp b/libcxx/test/containers/associative/map/map.access/at.pass.cpp index 09f70b0f88d9..6c001a34428c 100644 --- a/libcxx/test/containers/associative/map/map.access/at.pass.cpp +++ b/libcxx/test/containers/associative/map/map.access/at.pass.cpp @@ -17,6 +17,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -83,4 +85,70 @@ int main() assert(m.at(8) == 8.5); assert(m.size() == 7); } +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1.5), + V(2, 2.5), + V(3, 3.5), + V(4, 4.5), + V(5, 5.5), + V(7, 7.5), + V(8, 8.5), + }; + std::map, min_allocator> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 7); + assert(m.at(1) == 1.5); + m.at(1) = -1.5; + assert(m.at(1) == -1.5); + assert(m.at(2) == 2.5); + assert(m.at(3) == 3.5); + assert(m.at(4) == 4.5); + assert(m.at(5) == 5.5); + try + { + m.at(6); + assert(false); + } + catch (std::out_of_range&) + { + } + assert(m.at(7) == 7.5); + assert(m.at(8) == 8.5); + assert(m.size() == 7); + } + { + typedef std::pair V; + V ar[] = + { + V(1, 1.5), + V(2, 2.5), + V(3, 3.5), + V(4, 4.5), + V(5, 5.5), + V(7, 7.5), + V(8, 8.5), + }; + const std::map, min_allocator> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 7); + assert(m.at(1) == 1.5); + assert(m.at(2) == 2.5); + assert(m.at(3) == 3.5); + assert(m.at(4) == 4.5); + assert(m.at(5) == 5.5); + try + { + m.at(6); + assert(false); + } + catch (std::out_of_range&) + { + } + assert(m.at(7) == 7.5); + assert(m.at(8) == 8.5); + assert(m.size() == 7); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.access/empty.pass.cpp b/libcxx/test/containers/associative/map/map.access/empty.pass.cpp index b654117f7a7f..2e542ac8c321 100644 --- a/libcxx/test/containers/associative/map/map.access/empty.pass.cpp +++ b/libcxx/test/containers/associative/map/map.access/empty.pass.cpp @@ -16,8 +16,11 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { typedef std::map M; M m; assert(m.empty()); @@ -25,4 +28,16 @@ int main() assert(!m.empty()); m.clear(); assert(m.empty()); + } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> M; + M m; + assert(m.empty()); + m.insert(M::value_type(1, 1.5)); + assert(!m.empty()); + m.clear(); + assert(m.empty()); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.access/index_key.pass.cpp b/libcxx/test/containers/associative/map/map.access/index_key.pass.cpp index fb82bbedf812..7579088784c9 100644 --- a/libcxx/test/containers/associative/map/map.access/index_key.pass.cpp +++ b/libcxx/test/containers/associative/map/map.access/index_key.pass.cpp @@ -16,8 +16,11 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { typedef std::pair V; V ar[] = { @@ -41,4 +44,33 @@ int main() m[6] = 6.5; assert(m[6] == 6.5); assert(m.size() == 8); + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1.5), + V(2, 2.5), + V(3, 3.5), + V(4, 4.5), + V(5, 5.5), + V(7, 7.5), + V(8, 8.5), + }; + std::map, min_allocator> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 7); + assert(m[1] == 1.5); + assert(m.size() == 7); + const int i = 1; + m[i] = -1.5; + assert(m[1] == -1.5); + assert(m.size() == 7); + assert(m[6] == 0); + assert(m.size() == 8); + m[6] = 6.5; + assert(m[6] == 6.5); + assert(m.size() == 8); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.access/index_rv_key.pass.cpp b/libcxx/test/containers/associative/map/map.access/index_rv_key.pass.cpp index 4efe88c80d7f..4c15f088fae5 100644 --- a/libcxx/test/containers/associative/map/map.access/index_rv_key.pass.cpp +++ b/libcxx/test/containers/associative/map/map.access/index_rv_key.pass.cpp @@ -17,10 +17,12 @@ #include #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { typedef std::pair V; std::map m; assert(m.size() == 0); @@ -34,5 +36,23 @@ int main() m[6] = 6.5; assert(m[6] == 6.5); assert(m.size() == 2); + } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef std::pair V; + std::map, min_allocator> m; + assert(m.size() == 0); + assert(m[1] == 0.0); + assert(m.size() == 1); + m[1] = -1.5; + assert(m[1] == -1.5); + assert(m.size() == 1); + assert(m[6] == 0); + assert(m.size() == 2); + m[6] = 6.5; + assert(m[6] == 6.5); + assert(m.size() == 2); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.access/iterator.pass.cpp b/libcxx/test/containers/associative/map/map.access/iterator.pass.cpp index d8b2e1a58d5b..048c074c2960 100644 --- a/libcxx/test/containers/associative/map/map.access/iterator.pass.cpp +++ b/libcxx/test/containers/associative/map/map.access/iterator.pass.cpp @@ -29,6 +29,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -117,4 +119,92 @@ int main() assert(i->second == 1); } } +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + V(4, 1), + V(4, 1.5), + V(4, 2), + V(5, 1), + V(5, 1.5), + V(5, 2), + V(6, 1), + V(6, 1.5), + V(6, 2), + V(7, 1), + V(7, 1.5), + V(7, 2), + V(8, 1), + V(8, 1.5), + V(8, 2) + }; + std::map, min_allocator> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(std::distance(m.begin(), m.end()) == m.size()); + assert(std::distance(m.rbegin(), m.rend()) == m.size()); + std::map, min_allocator>::iterator i; + i = m.begin(); + std::map, min_allocator>::const_iterator k = i; + assert(i == k); + for (int j = 1; j <= m.size(); ++j, ++i) + { + assert(i->first == j); + assert(i->second == 1); + i->second = 2.5; + assert(i->second == 2.5); + } + } + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + V(4, 1), + V(4, 1.5), + V(4, 2), + V(5, 1), + V(5, 1.5), + V(5, 2), + V(6, 1), + V(6, 1.5), + V(6, 2), + V(7, 1), + V(7, 1.5), + V(7, 2), + V(8, 1), + V(8, 1.5), + V(8, 2) + }; + const std::map, min_allocator> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(std::distance(m.begin(), m.end()) == m.size()); + assert(std::distance(m.cbegin(), m.cend()) == m.size()); + assert(std::distance(m.rbegin(), m.rend()) == m.size()); + assert(std::distance(m.crbegin(), m.crend()) == m.size()); + std::map, min_allocator>::const_iterator i; + i = m.begin(); + for (int j = 1; j <= m.size(); ++j, ++i) + { + assert(i->first == j); + assert(i->second == 1); + } + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.access/max_size.pass.cpp b/libcxx/test/containers/associative/map/map.access/max_size.pass.cpp index e63587d4b434..6f86d0e9de84 100644 --- a/libcxx/test/containers/associative/map/map.access/max_size.pass.cpp +++ b/libcxx/test/containers/associative/map/map.access/max_size.pass.cpp @@ -16,9 +16,20 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { typedef std::map M; M m; assert(m.max_size() != 0); + } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> M; + M m; + assert(m.max_size() != 0); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.access/size.pass.cpp b/libcxx/test/containers/associative/map/map.access/size.pass.cpp index ab4d7c63c331..ab4b05baa5a6 100644 --- a/libcxx/test/containers/associative/map/map.access/size.pass.cpp +++ b/libcxx/test/containers/associative/map/map.access/size.pass.cpp @@ -16,8 +16,11 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { typedef std::map M; M m; assert(m.size() == 0); @@ -33,4 +36,24 @@ int main() assert(m.size() == 1); m.erase(m.begin()); assert(m.size() == 0); + } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> M; + M m; + assert(m.size() == 0); + m.insert(M::value_type(2, 1.5)); + assert(m.size() == 1); + m.insert(M::value_type(1, 1.5)); + assert(m.size() == 2); + m.insert(M::value_type(3, 1.5)); + assert(m.size() == 3); + m.erase(m.begin()); + assert(m.size() == 2); + m.erase(m.begin()); + assert(m.size() == 1); + m.erase(m.begin()); + assert(m.size() == 0); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/alloc.pass.cpp index 1a77f60564cc..95d71da664a8 100644 --- a/libcxx/test/containers/associative/map/map.cons/alloc.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/alloc.pass.cpp @@ -17,13 +17,26 @@ #include #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { + { typedef std::less C; typedef test_allocator > A; std::map m(A(5)); assert(m.empty()); assert(m.begin() == m.end()); assert(m.get_allocator() == A(5)); + } +#if __cplusplus >= 201103L + { + typedef std::less C; + typedef min_allocator > A; + std::map m(A{}); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.get_allocator() == A()); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp b/libcxx/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp index 2fdf5b294afc..a583f0d597fd 100644 --- a/libcxx/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::pair V; std::map m = { @@ -41,5 +44,32 @@ int main() assert(*m.begin() == V(1, 1)); assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + std::map, min_allocator> m = + { + {20, 1}, + }; + m = + { + {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }; + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/map/map.cons/compare.pass.cpp b/libcxx/test/containers/associative/map/map.cons/compare.pass.cpp index 5648ff0fb66f..2c4bb1a8cbc0 100644 --- a/libcxx/test/containers/associative/map/map.cons/compare.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/compare.pass.cpp @@ -17,12 +17,24 @@ #include #include "../../../test_compare.h" +#include "../../../min_allocator.h" int main() { + { typedef test_compare > C; std::map m(C(3)); assert(m.empty()); assert(m.begin() == m.end()); assert(m.key_comp() == C(3)); + } +#if __cplusplus >= 201103L + { + typedef test_compare > C; + std::map>> m(C(3)); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.key_comp() == C(3)); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/compare_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/compare_alloc.pass.cpp index 26efa0dabc84..670acffc4580 100644 --- a/libcxx/test/containers/associative/map/map.cons/compare_alloc.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/compare_alloc.pass.cpp @@ -18,9 +18,11 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { + { typedef test_compare > C; typedef test_allocator > A; std::map m(C(4), A(5)); @@ -28,4 +30,16 @@ int main() assert(m.begin() == m.end()); assert(m.key_comp() == C(4)); assert(m.get_allocator() == A(5)); + } +#if __cplusplus >= 201103L + { + typedef test_compare > C; + typedef min_allocator > A; + std::map m(C(4), A()); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.key_comp() == C(4)); + assert(m.get_allocator() == A()); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/copy.pass.cpp b/libcxx/test/containers/associative/map/map.cons/copy.pass.cpp index 01c0d89d5e42..ce20d69d7c9a 100644 --- a/libcxx/test/containers/associative/map/map.cons/copy.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/copy.pass.cpp @@ -18,6 +18,7 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -91,4 +92,40 @@ int main() assert(*next(mo.begin(), 2) == V(3, 1)); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare > C; + typedef min_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map m = mo; + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 3); + assert(distance(mo.begin(), mo.end()) == 3); + assert(*mo.begin() == V(1, 1)); + assert(*next(mo.begin()) == V(2, 1)); + assert(*next(mo.begin(), 2) == V(3, 1)); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/copy_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/copy_alloc.pass.cpp index 27b1c9710cc3..849240408ab8 100644 --- a/libcxx/test/containers/associative/map/map.cons/copy_alloc.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/copy_alloc.pass.cpp @@ -18,9 +18,11 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { + { typedef std::pair V; V ar[] = { @@ -53,4 +55,41 @@ int main() assert(*mo.begin() == V(1, 1)); assert(*next(mo.begin()) == V(2, 1)); assert(*next(mo.begin(), 2) == V(3, 1)); + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare > C; + typedef min_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map m(mo, A()); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 3); + assert(distance(mo.begin(), mo.end()) == 3); + assert(*mo.begin() == V(1, 1)); + assert(*next(mo.begin()) == V(2, 1)); + assert(*next(mo.begin(), 2) == V(3, 1)); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/copy_assign.pass.cpp b/libcxx/test/containers/associative/map/map.cons/copy_assign.pass.cpp index 7422ec99a905..fefb35ce7129 100644 --- a/libcxx/test/containers/associative/map/map.cons/copy_assign.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/copy_assign.pass.cpp @@ -18,6 +18,7 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -91,4 +92,76 @@ int main() assert(*next(mo.begin()) == V(2, 1)); assert(*next(mo.begin(), 2) == V(3, 1)); } +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2) + }; + typedef test_compare > C; + typedef min_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A()); + m = mo; + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 3); + assert(distance(mo.begin(), mo.end()) == 3); + assert(*mo.begin() == V(1, 1)); + assert(*next(mo.begin()) == V(2, 1)); + assert(*next(mo.begin(), 2) == V(3, 1)); + } + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2) + }; + typedef test_compare > C; + typedef min_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A()); + m = mo; + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 3); + assert(distance(mo.begin(), mo.end()) == 3); + assert(*mo.begin() == V(1, 1)); + assert(*next(mo.begin()) == V(2, 1)); + assert(*next(mo.begin(), 2) == V(3, 1)); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/default.pass.cpp b/libcxx/test/containers/associative/map/map.cons/default.pass.cpp index 8b5397c3def8..49fc223ffad5 100644 --- a/libcxx/test/containers/associative/map/map.cons/default.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/default.pass.cpp @@ -16,9 +16,20 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { std::map m; assert(m.empty()); assert(m.begin() == m.end()); + } +#if __cplusplus >= 201103L + { + std::map, min_allocator>> m; + assert(m.empty()); + assert(m.begin() == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/default_recursive.pass.cpp b/libcxx/test/containers/associative/map/map.cons/default_recursive.pass.cpp index 452746c87bbd..8b393d3c91c2 100644 --- a/libcxx/test/containers/associative/map/map.cons/default_recursive.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/default_recursive.pass.cpp @@ -19,7 +19,7 @@ struct X { - std::multimap m; + std::map m; }; #endif diff --git a/libcxx/test/containers/associative/map/map.cons/initializer_list.pass.cpp b/libcxx/test/containers/associative/map/map.cons/initializer_list.pass.cpp index 4acf2dcab51f..63820beea13b 100644 --- a/libcxx/test/containers/associative/map/map.cons/initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::pair V; std::map m = { @@ -37,5 +40,28 @@ int main() assert(*m.begin() == V(1, 1)); assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + std::map, min_allocator> m = + { + {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }; + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp b/libcxx/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp index 723a03f49d9a..0c3bd23a6357 100644 --- a/libcxx/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp @@ -16,10 +16,12 @@ #include #include #include "../../../test_compare.h" +#include "../../../min_allocator.h" int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::pair V; typedef test_compare > C; std::map m({ @@ -39,5 +41,29 @@ int main() assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); assert(m.key_comp() == C(3)); + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + typedef test_compare > C; + std::map>> m({ + {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }, C(3)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + assert(m.key_comp() == C(3)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp index f6300de20b9c..14e0eb3d4f70 100644 --- a/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp @@ -17,10 +17,12 @@ #include #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::pair V; typedef test_compare > C; typedef test_allocator > A; @@ -42,5 +44,31 @@ int main() assert(*next(m.begin(), 2) == V(3, 1)); assert(m.key_comp() == C(3)); assert(m.get_allocator() == A(6)); + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + typedef test_compare > C; + typedef min_allocator > A; + std::map m({ + {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }, C(3), A()); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + assert(m.key_comp() == C(3)); + assert(m.get_allocator() == A()); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/map/map.cons/iter_iter.pass.cpp b/libcxx/test/containers/associative/map/map.cons/iter_iter.pass.cpp index 00d3d8a27661..d981ccff8899 100644 --- a/libcxx/test/containers/associative/map/map.cons/iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/iter_iter.pass.cpp @@ -17,8 +17,11 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { typedef std::pair V; V ar[] = { @@ -38,4 +41,28 @@ int main() assert(*m.begin() == V(1, 1)); assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + std::map, min_allocator>> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp b/libcxx/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp index 6f851931ce9b..0481de24ccd5 100644 --- a/libcxx/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp @@ -18,9 +18,11 @@ #include #include "../../../test_compare.h" +#include "../../../min_allocator.h" int main() { + { typedef std::pair V; V ar[] = { @@ -42,4 +44,30 @@ int main() assert(*m.begin() == V(1, 1)); assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare > C; + std::map>> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5)); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp index abee6d9f0b0d..8fabdcc087df 100644 --- a/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp @@ -20,9 +20,11 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { + { typedef std::pair V; V ar[] = { @@ -46,4 +48,32 @@ int main() assert(*m.begin() == V(1, 1)); assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare > C; + typedef min_allocator A; + std::map m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/move.pass.cpp b/libcxx/test/containers/associative/map/map.cons/move.pass.cpp index b86dd6e382c4..323a26548e93 100644 --- a/libcxx/test/containers/associative/map/map.cons/move.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/move.pass.cpp @@ -18,6 +18,7 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -68,5 +69,52 @@ int main() assert(mo.size() == 0); assert(distance(mo.begin(), mo.end()) == 0); } +#if __cplusplus >= 201103L + { + typedef test_compare > C; + typedef min_allocator A; + std::map mo(C(5), A()); + std::map m = std::move(mo); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 0); + assert(distance(m.begin(), m.end()) == 0); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 0); + assert(distance(mo.begin(), mo.end()) == 0); + } + { + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare > C; + typedef min_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map m = std::move(mo); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 0); + assert(distance(mo.begin(), mo.end()) == 0); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/map/map.cons/move_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/move_alloc.pass.cpp index c9675dbd645c..2bb2c0612586 100644 --- a/libcxx/test/containers/associative/map/map.cons/move_alloc.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/move_alloc.pass.cpp @@ -19,6 +19,7 @@ #include "../../../MoveOnly.h" #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -140,5 +141,46 @@ int main() assert(m3.key_comp() == C(5)); assert(m1.empty()); } +#if __cplusplus >= 201103L + { + typedef std::pair V; + typedef std::pair VC; + typedef test_compare > C; + typedef min_allocator A; + typedef std::map M; + typedef std::move_iterator I; + V a1[] = + { + V(1, 1), + V(1, 2), + V(1, 3), + V(2, 1), + V(2, 2), + V(2, 3), + V(3, 1), + V(3, 2), + V(3, 3) + }; + M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A()); + V a2[] = + { + V(1, 1), + V(1, 2), + V(1, 3), + V(2, 1), + V(2, 2), + V(2, 3), + V(3, 1), + V(3, 2), + V(3, 3) + }; + M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A()); + M m3(std::move(m1), A()); + assert(m3 == m2); + assert(m3.get_allocator() == A()); + assert(m3.key_comp() == C(5)); + assert(m1.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/map/map.cons/move_assign.pass.cpp b/libcxx/test/containers/associative/map/map.cons/move_assign.pass.cpp index e8b9a88d97e1..2e6ede7bec7f 100644 --- a/libcxx/test/containers/associative/map/map.cons/move_assign.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/move_assign.pass.cpp @@ -19,6 +19,7 @@ #include "../../../MoveOnly.h" #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -143,5 +144,47 @@ int main() assert(m3.key_comp() == C(5)); assert(m1.empty()); } +#if __cplusplus >= 201103L + { + typedef std::pair V; + typedef std::pair VC; + typedef test_compare > C; + typedef min_allocator A; + typedef std::map M; + typedef std::move_iterator I; + V a1[] = + { + V(1, 1), + V(1, 2), + V(1, 3), + V(2, 1), + V(2, 2), + V(2, 3), + V(3, 1), + V(3, 2), + V(3, 3) + }; + M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A()); + V a2[] = + { + V(1, 1), + V(1, 2), + V(1, 3), + V(2, 1), + V(2, 2), + V(2, 3), + V(3, 1), + V(3, 2), + V(3, 3) + }; + M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A()); + M m3(C(3), A()); + m3 = std::move(m1); + assert(m3 == m2); + assert(m3.get_allocator() == A()); + assert(m3.key_comp() == C(5)); + assert(m1.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/map/map.modifiers/clear.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/clear.pass.cpp index a181e632e880..77f50badfef9 100644 --- a/libcxx/test/containers/associative/map/map.modifiers/clear.pass.cpp +++ b/libcxx/test/containers/associative/map/map.modifiers/clear.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -37,4 +39,25 @@ int main() m.clear(); assert(m.size() == 0); } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> M; + typedef std::pair P; + P ar[] = + { + P(1, 1.5), + P(2, 2.5), + P(3, 3.5), + P(4, 4.5), + P(5, 5.5), + P(6, 6.5), + P(7, 7.5), + P(8, 8.5), + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + m.clear(); + assert(m.size() == 0); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.modifiers/emplace.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/emplace.pass.cpp index 4eb7e9f832a4..3ade69db72e0 100644 --- a/libcxx/test/containers/associative/map/map.modifiers/emplace.pass.cpp +++ b/libcxx/test/containers/associative/map/map.modifiers/emplace.pass.cpp @@ -20,6 +20,7 @@ #include "../../../Emplaceable.h" #include "../../../DefaultOnly.h" +#include "../../../min_allocator.h" int main() { @@ -88,5 +89,71 @@ int main() assert(m.begin()->first == 2); assert(m.begin()->second == 3.5); } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> M; + typedef std::pair R; + M m; + assert(DefaultOnly::count == 0); + R r = m.emplace(); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(m.begin()->first == 0); + assert(m.begin()->second == DefaultOnly()); + assert(DefaultOnly::count == 1); + r = m.emplace(1); + assert(r.second); + assert(r.first == next(m.begin())); + assert(m.size() == 2); + assert(next(m.begin())->first == 1); + assert(next(m.begin())->second == DefaultOnly()); + assert(DefaultOnly::count == 2); + r = m.emplace(1); + assert(!r.second); + assert(r.first == next(m.begin())); + assert(m.size() == 2); + assert(next(m.begin())->first == 1); + assert(next(m.begin())->second == DefaultOnly()); + assert(DefaultOnly::count == 2); + } + assert(DefaultOnly::count == 0); + { + typedef std::map, min_allocator>> M; + typedef std::pair R; + M m; + R r = m.emplace(2); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(m.begin()->first == 2); + assert(m.begin()->second == Emplaceable()); + r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), + std::forward_as_tuple(2, 3.5)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 2); + assert(m.begin()->first == 1); + assert(m.begin()->second == Emplaceable(2, 3.5)); + r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), + std::forward_as_tuple(2, 3.5)); + assert(!r.second); + assert(r.first == m.begin()); + assert(m.size() == 2); + assert(m.begin()->first == 1); + assert(m.begin()->second == Emplaceable(2, 3.5)); + } + { + typedef std::map, min_allocator>> M; + typedef std::pair R; + M m; + R r = m.emplace(M::value_type(2, 3.5)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(m.begin()->first == 2); + assert(m.begin()->second == 3.5); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp index 2bc225e28a74..e1eb586d4873 100644 --- a/libcxx/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp +++ b/libcxx/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp @@ -19,6 +19,7 @@ #include "../../../Emplaceable.h" #include "../../../DefaultOnly.h" +#include "../../../min_allocator.h" int main() { @@ -82,5 +83,66 @@ int main() assert(m.begin()->first == 2); assert(m.begin()->second == 3.5); } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> M; + typedef M::iterator R; + M m; + assert(DefaultOnly::count == 0); + R r = m.emplace_hint(m.end()); + assert(r == m.begin()); + assert(m.size() == 1); + assert(m.begin()->first == 0); + assert(m.begin()->second == DefaultOnly()); + assert(DefaultOnly::count == 1); + r = m.emplace_hint(m.end(), 1); + assert(r == next(m.begin())); + assert(m.size() == 2); + assert(next(m.begin())->first == 1); + assert(next(m.begin())->second == DefaultOnly()); + assert(DefaultOnly::count == 2); + r = m.emplace_hint(m.end(), 1); + assert(r == next(m.begin())); + assert(m.size() == 2); + assert(next(m.begin())->first == 1); + assert(next(m.begin())->second == DefaultOnly()); + assert(DefaultOnly::count == 2); + } + assert(DefaultOnly::count == 0); + { + typedef std::map, min_allocator>> M; + typedef M::iterator R; + M m; + R r = m.emplace_hint(m.end(), 2); + assert(r == m.begin()); + assert(m.size() == 1); + assert(m.begin()->first == 2); + assert(m.begin()->second == Emplaceable()); + r = m.emplace_hint(m.end(), std::piecewise_construct, + std::forward_as_tuple(1), + std::forward_as_tuple(2, 3.5)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(m.begin()->first == 1); + assert(m.begin()->second == Emplaceable(2, 3.5)); + r = m.emplace_hint(m.end(), std::piecewise_construct, + std::forward_as_tuple(1), + std::forward_as_tuple(2, 3.5)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(m.begin()->first == 1); + assert(m.begin()->second == Emplaceable(2, 3.5)); + } + { + typedef std::map, min_allocator>> M; + typedef M::iterator R; + M m; + R r = m.emplace_hint(m.end(), M::value_type(2, 3.5)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(m.begin()->first == 2); + assert(m.begin()->second == 3.5); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp index caf16472e297..086096b7c8ba 100644 --- a/libcxx/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp +++ b/libcxx/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -124,4 +126,112 @@ int main() assert(i == m.begin()); assert(i == m.end()); } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> M; + typedef std::pair P; + typedef M::iterator I; + P ar[] = + { + P(1, 1.5), + P(2, 2.5), + P(3, 3.5), + P(4, 4.5), + P(5, 5.5), + P(6, 6.5), + P(7, 7.5), + P(8, 8.5), + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + I i = m.erase(next(m.cbegin(), 3)); + assert(m.size() == 7); + assert(i == next(m.begin(), 3)); + assert(m.begin()->first == 1); + assert(m.begin()->second == 1.5); + assert(next(m.begin())->first == 2); + assert(next(m.begin())->second == 2.5); + assert(next(m.begin(), 2)->first == 3); + assert(next(m.begin(), 2)->second == 3.5); + assert(next(m.begin(), 3)->first == 5); + assert(next(m.begin(), 3)->second == 5.5); + assert(next(m.begin(), 4)->first == 6); + assert(next(m.begin(), 4)->second == 6.5); + assert(next(m.begin(), 5)->first == 7); + assert(next(m.begin(), 5)->second == 7.5); + assert(next(m.begin(), 6)->first == 8); + assert(next(m.begin(), 6)->second == 8.5); + + i = m.erase(next(m.cbegin(), 0)); + assert(m.size() == 6); + assert(i == m.begin()); + assert(m.begin()->first == 2); + assert(m.begin()->second == 2.5); + assert(next(m.begin())->first == 3); + assert(next(m.begin())->second == 3.5); + assert(next(m.begin(), 2)->first == 5); + assert(next(m.begin(), 2)->second == 5.5); + assert(next(m.begin(), 3)->first == 6); + assert(next(m.begin(), 3)->second == 6.5); + assert(next(m.begin(), 4)->first == 7); + assert(next(m.begin(), 4)->second == 7.5); + assert(next(m.begin(), 5)->first == 8); + assert(next(m.begin(), 5)->second == 8.5); + + i = m.erase(next(m.cbegin(), 5)); + assert(m.size() == 5); + assert(i == m.end()); + assert(m.begin()->first == 2); + assert(m.begin()->second == 2.5); + assert(next(m.begin())->first == 3); + assert(next(m.begin())->second == 3.5); + assert(next(m.begin(), 2)->first == 5); + assert(next(m.begin(), 2)->second == 5.5); + assert(next(m.begin(), 3)->first == 6); + assert(next(m.begin(), 3)->second == 6.5); + assert(next(m.begin(), 4)->first == 7); + assert(next(m.begin(), 4)->second == 7.5); + + i = m.erase(next(m.cbegin(), 1)); + assert(m.size() == 4); + assert(i == next(m.begin())); + assert(m.begin()->first == 2); + assert(m.begin()->second == 2.5); + assert(next(m.begin())->first == 5); + assert(next(m.begin())->second == 5.5); + assert(next(m.begin(), 2)->first == 6); + assert(next(m.begin(), 2)->second == 6.5); + assert(next(m.begin(), 3)->first == 7); + assert(next(m.begin(), 3)->second == 7.5); + + i = m.erase(next(m.cbegin(), 2)); + assert(m.size() == 3); + assert(i == next(m.begin(), 2)); + assert(m.begin()->first == 2); + assert(m.begin()->second == 2.5); + assert(next(m.begin())->first == 5); + assert(next(m.begin())->second == 5.5); + assert(next(m.begin(), 2)->first == 7); + assert(next(m.begin(), 2)->second == 7.5); + + i = m.erase(next(m.cbegin(), 2)); + assert(m.size() == 2); + assert(i == next(m.begin(), 2)); + assert(m.begin()->first == 2); + assert(m.begin()->second == 2.5); + assert(next(m.begin())->first == 5); + assert(next(m.begin())->second == 5.5); + + i = m.erase(next(m.cbegin(), 0)); + assert(m.size() == 1); + assert(i == next(m.begin(), 0)); + assert(m.begin()->first == 5); + assert(m.begin()->second == 5.5); + + i = m.erase(m.cbegin()); + assert(m.size() == 0); + assert(i == m.begin()); + assert(i == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp index b595d8a07369..6589ace8ff1a 100644 --- a/libcxx/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -84,4 +86,72 @@ int main() assert(i == m.begin()); assert(i == m.end()); } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> M; + typedef std::pair P; + typedef M::iterator I; + P ar[] = + { + P(1, 1.5), + P(2, 2.5), + P(3, 3.5), + P(4, 4.5), + P(5, 5.5), + P(6, 6.5), + P(7, 7.5), + P(8, 8.5), + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + I i = m.erase(m.cbegin(), m.cbegin()); + assert(m.size() == 8); + assert(i == m.begin()); + assert(m.begin()->first == 1); + assert(m.begin()->second == 1.5); + assert(next(m.begin())->first == 2); + assert(next(m.begin())->second == 2.5); + assert(next(m.begin(), 2)->first == 3); + assert(next(m.begin(), 2)->second == 3.5); + assert(next(m.begin(), 3)->first == 4); + assert(next(m.begin(), 3)->second == 4.5); + assert(next(m.begin(), 4)->first == 5); + assert(next(m.begin(), 4)->second == 5.5); + assert(next(m.begin(), 5)->first == 6); + assert(next(m.begin(), 5)->second == 6.5); + assert(next(m.begin(), 6)->first == 7); + assert(next(m.begin(), 6)->second == 7.5); + assert(next(m.begin(), 7)->first == 8); + assert(next(m.begin(), 7)->second == 8.5); + + i = m.erase(m.cbegin(), next(m.cbegin(), 2)); + assert(m.size() == 6); + assert(i == m.begin()); + assert(next(m.begin(), 0)->first == 3); + assert(next(m.begin(), 0)->second == 3.5); + assert(next(m.begin(), 1)->first == 4); + assert(next(m.begin(), 1)->second == 4.5); + assert(next(m.begin(), 2)->first == 5); + assert(next(m.begin(), 2)->second == 5.5); + assert(next(m.begin(), 3)->first == 6); + assert(next(m.begin(), 3)->second == 6.5); + assert(next(m.begin(), 4)->first == 7); + assert(next(m.begin(), 4)->second == 7.5); + assert(next(m.begin(), 5)->first == 8); + assert(next(m.begin(), 5)->second == 8.5); + + i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6)); + assert(m.size() == 2); + assert(i == next(m.begin(), 2)); + assert(next(m.begin(), 0)->first == 3); + assert(next(m.begin(), 0)->second == 3.5); + assert(next(m.begin(), 1)->first == 4); + assert(next(m.begin(), 1)->second == 4.5); + + i = m.erase(m.cbegin(), m.cend()); + assert(m.size() == 0); + assert(i == m.begin()); + assert(i == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.modifiers/erase_key.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/erase_key.pass.cpp index e78a00ff74e8..4a93173a7044 100644 --- a/libcxx/test/containers/associative/map/map.modifiers/erase_key.pass.cpp +++ b/libcxx/test/containers/associative/map/map.modifiers/erase_key.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -143,4 +145,131 @@ int main() assert(m.size() == 0); assert(s == 1); } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> M; + typedef std::pair P; + typedef M::size_type R; + P ar[] = + { + P(1, 1.5), + P(2, 2.5), + P(3, 3.5), + P(4, 4.5), + P(5, 5.5), + P(6, 6.5), + P(7, 7.5), + P(8, 8.5), + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + R s = m.erase(9); + assert(s == 0); + assert(m.size() == 8); + assert(m.begin()->first == 1); + assert(m.begin()->second == 1.5); + assert(next(m.begin())->first == 2); + assert(next(m.begin())->second == 2.5); + assert(next(m.begin(), 2)->first == 3); + assert(next(m.begin(), 2)->second == 3.5); + assert(next(m.begin(), 3)->first == 4); + assert(next(m.begin(), 3)->second == 4.5); + assert(next(m.begin(), 4)->first == 5); + assert(next(m.begin(), 4)->second == 5.5); + assert(next(m.begin(), 5)->first == 6); + assert(next(m.begin(), 5)->second == 6.5); + assert(next(m.begin(), 6)->first == 7); + assert(next(m.begin(), 6)->second == 7.5); + assert(next(m.begin(), 7)->first == 8); + assert(next(m.begin(), 7)->second == 8.5); + + s = m.erase(4); + assert(m.size() == 7); + assert(s == 1); + assert(m.begin()->first == 1); + assert(m.begin()->second == 1.5); + assert(next(m.begin())->first == 2); + assert(next(m.begin())->second == 2.5); + assert(next(m.begin(), 2)->first == 3); + assert(next(m.begin(), 2)->second == 3.5); + assert(next(m.begin(), 3)->first == 5); + assert(next(m.begin(), 3)->second == 5.5); + assert(next(m.begin(), 4)->first == 6); + assert(next(m.begin(), 4)->second == 6.5); + assert(next(m.begin(), 5)->first == 7); + assert(next(m.begin(), 5)->second == 7.5); + assert(next(m.begin(), 6)->first == 8); + assert(next(m.begin(), 6)->second == 8.5); + + s = m.erase(1); + assert(m.size() == 6); + assert(s == 1); + assert(m.begin()->first == 2); + assert(m.begin()->second == 2.5); + assert(next(m.begin())->first == 3); + assert(next(m.begin())->second == 3.5); + assert(next(m.begin(), 2)->first == 5); + assert(next(m.begin(), 2)->second == 5.5); + assert(next(m.begin(), 3)->first == 6); + assert(next(m.begin(), 3)->second == 6.5); + assert(next(m.begin(), 4)->first == 7); + assert(next(m.begin(), 4)->second == 7.5); + assert(next(m.begin(), 5)->first == 8); + assert(next(m.begin(), 5)->second == 8.5); + + s = m.erase(8); + assert(m.size() == 5); + assert(s == 1); + assert(m.begin()->first == 2); + assert(m.begin()->second == 2.5); + assert(next(m.begin())->first == 3); + assert(next(m.begin())->second == 3.5); + assert(next(m.begin(), 2)->first == 5); + assert(next(m.begin(), 2)->second == 5.5); + assert(next(m.begin(), 3)->first == 6); + assert(next(m.begin(), 3)->second == 6.5); + assert(next(m.begin(), 4)->first == 7); + assert(next(m.begin(), 4)->second == 7.5); + + s = m.erase(3); + assert(m.size() == 4); + assert(s == 1); + assert(m.begin()->first == 2); + assert(m.begin()->second == 2.5); + assert(next(m.begin())->first == 5); + assert(next(m.begin())->second == 5.5); + assert(next(m.begin(), 2)->first == 6); + assert(next(m.begin(), 2)->second == 6.5); + assert(next(m.begin(), 3)->first == 7); + assert(next(m.begin(), 3)->second == 7.5); + + s = m.erase(6); + assert(m.size() == 3); + assert(s == 1); + assert(m.begin()->first == 2); + assert(m.begin()->second == 2.5); + assert(next(m.begin())->first == 5); + assert(next(m.begin())->second == 5.5); + assert(next(m.begin(), 2)->first == 7); + assert(next(m.begin(), 2)->second == 7.5); + + s = m.erase(7); + assert(m.size() == 2); + assert(s == 1); + assert(m.begin()->first == 2); + assert(m.begin()->second == 2.5); + assert(next(m.begin())->first == 5); + assert(next(m.begin())->second == 5.5); + + s = m.erase(2); + assert(m.size() == 1); + assert(s == 1); + assert(m.begin()->first == 5); + assert(m.begin()->second == 5.5); + + s = m.erase(5); + assert(m.size() == 0); + assert(s == 1); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp index f405c4c37655..24d3f84ea305 100644 --- a/libcxx/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp +++ b/libcxx/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -50,4 +52,38 @@ int main() assert(r.first->first == 3); assert(r.first->second == 3.5); } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> M; + typedef std::pair R; + M m; + R r = m.insert(M::value_type(2, 2.5)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(r.first->first == 2); + assert(r.first->second == 2.5); + + r = m.insert(M::value_type(1, 1.5)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 2); + assert(r.first->first == 1); + assert(r.first->second == 1.5); + + r = m.insert(M::value_type(3, 3.5)); + assert(r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(r.first->first == 3); + assert(r.first->second == 3.5); + + r = m.insert(M::value_type(3, 3.5)); + assert(!r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(r.first->first == 3); + assert(r.first->second == 3.5); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp index 66714d53eb5c..bc7e760fad06 100644 --- a/libcxx/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::pair V; std::map m = { @@ -39,5 +42,30 @@ int main() assert(*m.begin() == V(1, 1)); assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + std::map, min_allocator> m = + { + {1, 1}, + {1, 1.5}, + {1, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }; + m.insert({ + {2, 1}, + {2, 1.5}, + {2, 2}, + }); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp index 105b4564dcda..43ca35a099fe 100644 --- a/libcxx/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp +++ b/libcxx/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -46,4 +48,34 @@ int main() assert(r->first == 3); assert(r->second == 3.5); } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> M; + typedef M::iterator R; + M m; + R r = m.insert(m.end(), M::value_type(2, 2.5)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2.5); + + r = m.insert(m.end(), M::value_type(1, 1.5)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1.5); + + r = m.insert(m.end(), M::value_type(3, 3.5)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3.5); + + r = m.insert(m.end(), M::value_type(3, 3.5)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3.5); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp index 307e3e42f393..d1acdf2b8269 100644 --- a/libcxx/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp @@ -18,6 +18,7 @@ #include #include "test_iterators.h" +#include "../../../min_allocator.h" int main() { @@ -46,4 +47,31 @@ int main() assert(next(m.begin(), 2)->first == 3); assert(next(m.begin(), 2)->second == 1); } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> M; + typedef std::pair P; + P ar[] = + { + P(1, 1), + P(1, 1.5), + P(1, 2), + P(2, 1), + P(2, 1.5), + P(2, 2), + P(3, 1), + P(3, 1.5), + P(3, 2), + }; + M m; + m.insert(input_iterator(ar), input_iterator(ar + sizeof(ar)/sizeof(ar[0]))); + assert(m.size() == 3); + assert(m.begin()->first == 1); + assert(m.begin()->second == 1); + assert(next(m.begin())->first == 2); + assert(next(m.begin())->second == 1); + assert(next(m.begin(), 2)->first == 3); + assert(next(m.begin(), 2)->second == 1); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp index 620c0159033e..e84a82b609a8 100644 --- a/libcxx/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp +++ b/libcxx/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp @@ -18,6 +18,7 @@ #include #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -51,5 +52,36 @@ int main() assert(r->first == 3); assert(r->second == 3); } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> M; + typedef std::pair P; + typedef M::iterator R; + M m; + R r = m.insert(m.end(), P(2, 2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2); + + r = m.insert(m.end(), P(1, 1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1); + + r = m.insert(m.end(), P(3, 3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3); + + r = m.insert(m.end(), P(3, 3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp index b95202b32f85..c5724c42980b 100644 --- a/libcxx/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp +++ b/libcxx/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp @@ -18,6 +18,7 @@ #include #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -54,5 +55,39 @@ int main() assert(r.first->first == 3); assert(r.first->second == 3); } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> M; + typedef std::pair R; + M m; + R r = m.insert(M::value_type(2, 2)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(r.first->first == 2); + assert(r.first->second == 2); + + r = m.insert(M::value_type(1, 1)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 2); + assert(r.first->first == 1); + assert(r.first->second == 1); + + r = m.insert(M::value_type(3, 3)); + assert(r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(r.first->first == 3); + assert(r.first->second == 3); + + r = m.insert(M::value_type(3, 3)); + assert(!r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(r.first->first == 3); + assert(r.first->second == 3); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/map/map.ops/count.pass.cpp b/libcxx/test/containers/associative/map/map.ops/count.pass.cpp index 427feff970ba..70eadac3f8f4 100644 --- a/libcxx/test/containers/associative/map/map.ops/count.pass.cpp +++ b/libcxx/test/containers/associative/map/map.ops/count.pass.cpp @@ -16,8 +16,11 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { typedef std::pair V; typedef std::map M; { @@ -53,4 +56,44 @@ int main() r = m.count(4); assert(r == 0); } + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + typedef std::map, min_allocator> M; + { + typedef M::size_type R; + V ar[] = + { + V(5, 5), + V(6, 6), + V(7, 7), + V(8, 8), + V(9, 9), + V(10, 10), + V(11, 11), + V(12, 12) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.count(5); + assert(r == 1); + r = m.count(6); + assert(r == 1); + r = m.count(7); + assert(r == 1); + r = m.count(8); + assert(r == 1); + r = m.count(9); + assert(r == 1); + r = m.count(10); + assert(r == 1); + r = m.count(11); + assert(r == 1); + r = m.count(12); + assert(r == 1); + r = m.count(4); + assert(r == 0); + } + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.ops/equal_range.pass.cpp b/libcxx/test/containers/associative/map/map.ops/equal_range.pass.cpp index 057ef6a44588..dc0d09760a9d 100644 --- a/libcxx/test/containers/associative/map/map.ops/equal_range.pass.cpp +++ b/libcxx/test/containers/associative/map/map.ops/equal_range.pass.cpp @@ -17,8 +17,11 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { typedef std::pair V; typedef std::map M; { @@ -153,4 +156,143 @@ int main() assert(r.first == next(m.begin(), 8)); assert(r.second == next(m.begin(), 8)); } + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + typedef std::map, min_allocator> M; + { + typedef std::pair R; + V ar[] = + { + V(5, 5), + V(7, 6), + V(9, 7), + V(11, 8), + V(13, 9), + V(15, 10), + V(17, 11), + V(19, 12) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.equal_range(5); + assert(r.first == next(m.begin(), 0)); + assert(r.second == next(m.begin(), 1)); + r = m.equal_range(7); + assert(r.first == next(m.begin(), 1)); + assert(r.second == next(m.begin(), 2)); + r = m.equal_range(9); + assert(r.first == next(m.begin(), 2)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(11); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 4)); + r = m.equal_range(13); + assert(r.first == next(m.begin(), 4)); + assert(r.second == next(m.begin(), 5)); + r = m.equal_range(15); + assert(r.first == next(m.begin(), 5)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(17); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 7)); + r = m.equal_range(19); + assert(r.first == next(m.begin(), 7)); + assert(r.second == next(m.begin(), 8)); + r = m.equal_range(4); + assert(r.first == next(m.begin(), 0)); + assert(r.second == next(m.begin(), 0)); + r = m.equal_range(6); + assert(r.first == next(m.begin(), 1)); + assert(r.second == next(m.begin(), 1)); + r = m.equal_range(8); + assert(r.first == next(m.begin(), 2)); + assert(r.second == next(m.begin(), 2)); + r = m.equal_range(10); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(12); + assert(r.first == next(m.begin(), 4)); + assert(r.second == next(m.begin(), 4)); + r = m.equal_range(14); + assert(r.first == next(m.begin(), 5)); + assert(r.second == next(m.begin(), 5)); + r = m.equal_range(16); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(18); + assert(r.first == next(m.begin(), 7)); + assert(r.second == next(m.begin(), 7)); + r = m.equal_range(20); + assert(r.first == next(m.begin(), 8)); + assert(r.second == next(m.begin(), 8)); + } + { + typedef std::pair R; + V ar[] = + { + V(5, 5), + V(7, 6), + V(9, 7), + V(11, 8), + V(13, 9), + V(15, 10), + V(17, 11), + V(19, 12) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.equal_range(5); + assert(r.first == next(m.begin(), 0)); + assert(r.second == next(m.begin(), 1)); + r = m.equal_range(7); + assert(r.first == next(m.begin(), 1)); + assert(r.second == next(m.begin(), 2)); + r = m.equal_range(9); + assert(r.first == next(m.begin(), 2)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(11); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 4)); + r = m.equal_range(13); + assert(r.first == next(m.begin(), 4)); + assert(r.second == next(m.begin(), 5)); + r = m.equal_range(15); + assert(r.first == next(m.begin(), 5)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(17); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 7)); + r = m.equal_range(19); + assert(r.first == next(m.begin(), 7)); + assert(r.second == next(m.begin(), 8)); + r = m.equal_range(4); + assert(r.first == next(m.begin(), 0)); + assert(r.second == next(m.begin(), 0)); + r = m.equal_range(6); + assert(r.first == next(m.begin(), 1)); + assert(r.second == next(m.begin(), 1)); + r = m.equal_range(8); + assert(r.first == next(m.begin(), 2)); + assert(r.second == next(m.begin(), 2)); + r = m.equal_range(10); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(12); + assert(r.first == next(m.begin(), 4)); + assert(r.second == next(m.begin(), 4)); + r = m.equal_range(14); + assert(r.first == next(m.begin(), 5)); + assert(r.second == next(m.begin(), 5)); + r = m.equal_range(16); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(18); + assert(r.first == next(m.begin(), 7)); + assert(r.second == next(m.begin(), 7)); + r = m.equal_range(20); + assert(r.first == next(m.begin(), 8)); + assert(r.second == next(m.begin(), 8)); + } + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.ops/find.pass.cpp b/libcxx/test/containers/associative/map/map.ops/find.pass.cpp index afebf1294748..a368dc5e7aa0 100644 --- a/libcxx/test/containers/associative/map/map.ops/find.pass.cpp +++ b/libcxx/test/containers/associative/map/map.ops/find.pass.cpp @@ -17,8 +17,11 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { typedef std::pair V; typedef std::map M; { @@ -87,4 +90,77 @@ int main() r = m.find(4); assert(r == next(m.begin(), 8)); } + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + typedef std::map, min_allocator> M; + { + typedef M::iterator R; + V ar[] = + { + V(5, 5), + V(6, 6), + V(7, 7), + V(8, 8), + V(9, 9), + V(10, 10), + V(11, 11), + V(12, 12) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == next(m.begin())); + r = m.find(7); + assert(r == next(m.begin(), 2)); + r = m.find(8); + assert(r == next(m.begin(), 3)); + r = m.find(9); + assert(r == next(m.begin(), 4)); + r = m.find(10); + assert(r == next(m.begin(), 5)); + r = m.find(11); + assert(r == next(m.begin(), 6)); + r = m.find(12); + assert(r == next(m.begin(), 7)); + r = m.find(4); + assert(r == next(m.begin(), 8)); + } + { + typedef M::const_iterator R; + V ar[] = + { + V(5, 5), + V(6, 6), + V(7, 7), + V(8, 8), + V(9, 9), + V(10, 10), + V(11, 11), + V(12, 12) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == next(m.begin())); + r = m.find(7); + assert(r == next(m.begin(), 2)); + r = m.find(8); + assert(r == next(m.begin(), 3)); + r = m.find(9); + assert(r == next(m.begin(), 4)); + r = m.find(10); + assert(r == next(m.begin(), 5)); + r = m.find(11); + assert(r == next(m.begin(), 6)); + r = m.find(12); + assert(r == next(m.begin(), 7)); + r = m.find(4); + assert(r == next(m.begin(), 8)); + } + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.ops/lower_bound.pass.cpp b/libcxx/test/containers/associative/map/map.ops/lower_bound.pass.cpp index f2f03cf37fe6..a1b8e5b3c2ea 100644 --- a/libcxx/test/containers/associative/map/map.ops/lower_bound.pass.cpp +++ b/libcxx/test/containers/associative/map/map.ops/lower_bound.pass.cpp @@ -17,8 +17,11 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { typedef std::pair V; typedef std::map M; { @@ -119,4 +122,109 @@ int main() r = m.lower_bound(20); assert(r == next(m.begin(), 8)); } + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + typedef std::map, min_allocator> M; + { + typedef M::iterator R; + V ar[] = + { + V(5, 5), + V(7, 6), + V(9, 7), + V(11, 8), + V(13, 9), + V(15, 10), + V(17, 11), + V(19, 12) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(5); + assert(r == m.begin()); + r = m.lower_bound(7); + assert(r == next(m.begin())); + r = m.lower_bound(9); + assert(r == next(m.begin(), 2)); + r = m.lower_bound(11); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(13); + assert(r == next(m.begin(), 4)); + r = m.lower_bound(15); + assert(r == next(m.begin(), 5)); + r = m.lower_bound(17); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(19); + assert(r == next(m.begin(), 7)); + r = m.lower_bound(4); + assert(r == next(m.begin(), 0)); + r = m.lower_bound(6); + assert(r == next(m.begin(), 1)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 2)); + r = m.lower_bound(10); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(12); + assert(r == next(m.begin(), 4)); + r = m.lower_bound(14); + assert(r == next(m.begin(), 5)); + r = m.lower_bound(16); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(18); + assert(r == next(m.begin(), 7)); + r = m.lower_bound(20); + assert(r == next(m.begin(), 8)); + } + { + typedef M::const_iterator R; + V ar[] = + { + V(5, 5), + V(7, 6), + V(9, 7), + V(11, 8), + V(13, 9), + V(15, 10), + V(17, 11), + V(19, 12) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(5); + assert(r == m.begin()); + r = m.lower_bound(7); + assert(r == next(m.begin())); + r = m.lower_bound(9); + assert(r == next(m.begin(), 2)); + r = m.lower_bound(11); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(13); + assert(r == next(m.begin(), 4)); + r = m.lower_bound(15); + assert(r == next(m.begin(), 5)); + r = m.lower_bound(17); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(19); + assert(r == next(m.begin(), 7)); + r = m.lower_bound(4); + assert(r == next(m.begin(), 0)); + r = m.lower_bound(6); + assert(r == next(m.begin(), 1)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 2)); + r = m.lower_bound(10); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(12); + assert(r == next(m.begin(), 4)); + r = m.lower_bound(14); + assert(r == next(m.begin(), 5)); + r = m.lower_bound(16); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(18); + assert(r == next(m.begin(), 7)); + r = m.lower_bound(20); + assert(r == next(m.begin(), 8)); + } + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.ops/upper_bound.pass.cpp b/libcxx/test/containers/associative/map/map.ops/upper_bound.pass.cpp index 0d97e70ee4ad..eee08aee31bd 100644 --- a/libcxx/test/containers/associative/map/map.ops/upper_bound.pass.cpp +++ b/libcxx/test/containers/associative/map/map.ops/upper_bound.pass.cpp @@ -17,8 +17,11 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { typedef std::pair V; typedef std::map M; { @@ -119,4 +122,109 @@ int main() r = m.upper_bound(20); assert(r == next(m.begin(), 8)); } + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + typedef std::map, min_allocator> M; + { + typedef M::iterator R; + V ar[] = + { + V(5, 5), + V(7, 6), + V(9, 7), + V(11, 8), + V(13, 9), + V(15, 10), + V(17, 11), + V(19, 12) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(5); + assert(r == next(m.begin(), 1)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 2)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(11); + assert(r == next(m.begin(), 4)); + r = m.upper_bound(13); + assert(r == next(m.begin(), 5)); + r = m.upper_bound(15); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(17); + assert(r == next(m.begin(), 7)); + r = m.upper_bound(19); + assert(r == next(m.begin(), 8)); + r = m.upper_bound(4); + assert(r == next(m.begin(), 0)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 1)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 2)); + r = m.upper_bound(10); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(12); + assert(r == next(m.begin(), 4)); + r = m.upper_bound(14); + assert(r == next(m.begin(), 5)); + r = m.upper_bound(16); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(18); + assert(r == next(m.begin(), 7)); + r = m.upper_bound(20); + assert(r == next(m.begin(), 8)); + } + { + typedef M::const_iterator R; + V ar[] = + { + V(5, 5), + V(7, 6), + V(9, 7), + V(11, 8), + V(13, 9), + V(15, 10), + V(17, 11), + V(19, 12) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(5); + assert(r == next(m.begin(), 1)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 2)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(11); + assert(r == next(m.begin(), 4)); + r = m.upper_bound(13); + assert(r == next(m.begin(), 5)); + r = m.upper_bound(15); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(17); + assert(r == next(m.begin(), 7)); + r = m.upper_bound(19); + assert(r == next(m.begin(), 8)); + r = m.upper_bound(4); + assert(r == next(m.begin(), 0)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 1)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 2)); + r = m.upper_bound(10); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(12); + assert(r == next(m.begin(), 4)); + r = m.upper_bound(14); + assert(r == next(m.begin(), 5)); + r = m.upper_bound(16); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(18); + assert(r == next(m.begin(), 7)); + r = m.upper_bound(20); + assert(r == next(m.begin(), 8)); + } + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.special/member_swap.pass.cpp b/libcxx/test/containers/associative/map/map.special/member_swap.pass.cpp index 84513450e50b..af5922526a08 100644 --- a/libcxx/test/containers/associative/map/map.special/member_swap.pass.cpp +++ b/libcxx/test/containers/associative/map/map.special/member_swap.pass.cpp @@ -16,8 +16,11 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { typedef std::pair V; typedef std::map M; { @@ -104,4 +107,95 @@ int main() assert(m1 == m2_save); assert(m2 == m1_save); } + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + typedef std::map, min_allocator> M; + { + V ar1[] = + { + }; + V ar2[] = + { + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + }; + V ar2[] = + { + V(5, 5), + V(6, 6), + V(7, 7), + V(8, 8), + V(9, 9), + V(10, 10), + V(11, 11), + V(12, 12) + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + V(1, 1), + V(2, 2), + V(3, 3), + V(4, 4) + }; + V ar2[] = + { + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + V(1, 1), + V(2, 2), + V(3, 3), + V(4, 4) + }; + V ar2[] = + { + V(5, 5), + V(6, 6), + V(7, 7), + V(8, 8), + V(9, 9), + V(10, 10), + V(11, 11), + V(12, 12) + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.special/non_member_swap.pass.cpp b/libcxx/test/containers/associative/map/map.special/non_member_swap.pass.cpp index ef67892a7a76..e474a4661bb7 100644 --- a/libcxx/test/containers/associative/map/map.special/non_member_swap.pass.cpp +++ b/libcxx/test/containers/associative/map/map.special/non_member_swap.pass.cpp @@ -19,9 +19,11 @@ #include #include "../../../test_allocator.h" #include "../../../test_compare.h" +#include "../../../min_allocator.h" int main() { + { typedef std::pair V; typedef std::map M; { @@ -176,4 +178,129 @@ int main() assert(m2.key_comp() == C(1)); assert(m2.get_allocator() == A(1)); } + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + typedef std::map, min_allocator> M; + { + V ar1[] = + { + }; + V ar2[] = + { + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + swap(m1, m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + }; + V ar2[] = + { + V(5, 5), + V(6, 6), + V(7, 7), + V(8, 8), + V(9, 9), + V(10, 10), + V(11, 11), + V(12, 12) + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + swap(m1, m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + V(1, 1), + V(2, 2), + V(3, 3), + V(4, 4) + }; + V ar2[] = + { + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + swap(m1, m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + V(1, 1), + V(2, 2), + V(3, 3), + V(4, 4) + }; + V ar2[] = + { + V(5, 5), + V(6, 6), + V(7, 7), + V(8, 8), + V(9, 9), + V(10, 10), + V(11, 11), + V(12, 12) + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + swap(m1, m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + typedef min_allocator A; + typedef test_compare > C; + typedef std::map M; + V ar1[] = + { + V(1, 1), + V(2, 2), + V(3, 3), + V(4, 4) + }; + V ar2[] = + { + V(5, 5), + V(6, 6), + V(7, 7), + V(8, 8), + V(9, 9), + V(10, 10), + V(11, 11), + V(12, 12) + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A()); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A()); + M m1_save = m1; + M m2_save = m2; + swap(m1, m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + assert(m1.key_comp() == C(2)); + assert(m1.get_allocator() == A()); + assert(m2.key_comp() == C(1)); + assert(m2.get_allocator() == A()); + } + } +#endif } diff --git a/libcxx/test/containers/associative/map/types.pass.cpp b/libcxx/test/containers/associative/map/types.pass.cpp index 313b7bdbbac4..aca81dfb964d 100644 --- a/libcxx/test/containers/associative/map/types.pass.cpp +++ b/libcxx/test/containers/associative/map/types.pass.cpp @@ -32,8 +32,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { static_assert((std::is_same::key_type, int>::value), ""); static_assert((std::is_same::mapped_type, double>::value), ""); static_assert((std::is_same::value_type, std::pair >::value), ""); @@ -45,4 +48,20 @@ int main() static_assert((std::is_same::const_pointer, const std::pair*>::value), ""); static_assert((std::is_same::size_type, std::size_t>::value), ""); static_assert((std::is_same::difference_type, std::ptrdiff_t>::value), ""); + } +#if __cplusplus >= 201103L + { + static_assert((std::is_same, min_allocator>>::key_type, int>::value), ""); + static_assert((std::is_same, min_allocator>>::mapped_type, double>::value), ""); + static_assert((std::is_same, min_allocator>>::value_type, std::pair >::value), ""); + static_assert((std::is_same, min_allocator>>::key_compare, std::less >::value), ""); + static_assert((std::is_same, min_allocator>>::allocator_type, min_allocator > >::value), ""); + static_assert((std::is_same, min_allocator>>::reference, std::pair&>::value), ""); + static_assert((std::is_same, min_allocator>>::const_reference, const std::pair&>::value), ""); + static_assert((std::is_same, min_allocator>>::pointer, min_pointer>>::value), ""); + static_assert((std::is_same, min_allocator>>::const_pointer, min_pointer>>::value), ""); + static_assert((std::is_same, min_allocator>>::size_type, std::size_t>::value), ""); + static_assert((std::is_same, min_allocator>>::difference_type, std::ptrdiff_t>::value), ""); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/empty.pass.cpp b/libcxx/test/containers/associative/multimap/empty.pass.cpp index c54920e03bd5..cafdb7344c8f 100644 --- a/libcxx/test/containers/associative/multimap/empty.pass.cpp +++ b/libcxx/test/containers/associative/multimap/empty.pass.cpp @@ -16,8 +16,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef std::multimap M; M m; assert(m.empty()); @@ -25,4 +28,16 @@ int main() assert(!m.empty()); m.clear(); assert(m.empty()); + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + M m; + assert(m.empty()); + m.insert(M::value_type(1, 1.5)); + assert(!m.empty()); + m.clear(); + assert(m.empty()); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/iterator.pass.cpp b/libcxx/test/containers/associative/multimap/iterator.pass.cpp index dfb2fdf5cd8a..283b32dc9123 100644 --- a/libcxx/test/containers/associative/multimap/iterator.pass.cpp +++ b/libcxx/test/containers/associative/multimap/iterator.pass.cpp @@ -29,6 +29,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -119,4 +121,94 @@ int main() assert(i->second == d); } } +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + V(4, 1), + V(4, 1.5), + V(4, 2), + V(5, 1), + V(5, 1.5), + V(5, 2), + V(6, 1), + V(6, 1.5), + V(6, 2), + V(7, 1), + V(7, 1.5), + V(7, 2), + V(8, 1), + V(8, 1.5), + V(8, 2) + }; + std::multimap, min_allocator> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(std::distance(m.begin(), m.end()) == m.size()); + assert(std::distance(m.rbegin(), m.rend()) == m.size()); + std::multimap, min_allocator>::iterator i; + i = m.begin(); + std::multimap, min_allocator>::const_iterator k = i; + assert(i == k); + for (int j = 1; j <= 8; ++j) + for (double d = 1; d <= 2; d += .5, ++i) + { + assert(i->first == j); + assert(i->second == d); + i->second = 2.5; + assert(i->second == 2.5); + } + } + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + V(4, 1), + V(4, 1.5), + V(4, 2), + V(5, 1), + V(5, 1.5), + V(5, 2), + V(6, 1), + V(6, 1.5), + V(6, 2), + V(7, 1), + V(7, 1.5), + V(7, 2), + V(8, 1), + V(8, 1.5), + V(8, 2) + }; + const std::multimap, min_allocator> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(std::distance(m.begin(), m.end()) == m.size()); + assert(std::distance(m.cbegin(), m.cend()) == m.size()); + assert(std::distance(m.rbegin(), m.rend()) == m.size()); + assert(std::distance(m.crbegin(), m.crend()) == m.size()); + std::multimap, min_allocator>::const_iterator i; + i = m.begin(); + for (int j = 1; j <= 8; ++j) + for (double d = 1; d <= 2; d += .5, ++i) + { + assert(i->first == j); + assert(i->second == d); + } + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/max_size.pass.cpp b/libcxx/test/containers/associative/multimap/max_size.pass.cpp index 2fcd56916ad7..7bcb12a2e805 100644 --- a/libcxx/test/containers/associative/multimap/max_size.pass.cpp +++ b/libcxx/test/containers/associative/multimap/max_size.pass.cpp @@ -16,9 +16,20 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef std::multimap M; M m; assert(m.max_size() != 0); + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + M m; + assert(m.max_size() != 0); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/alloc.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/alloc.pass.cpp index 3087c2e44084..aa3b6e2e6d28 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/alloc.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/alloc.pass.cpp @@ -17,13 +17,26 @@ #include #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { + { typedef std::less C; typedef test_allocator > A; std::multimap m(A(5)); assert(m.empty()); assert(m.begin() == m.end()); assert(m.get_allocator() == A(5)); + } +#if __cplusplus >= 201103L + { + typedef std::less C; + typedef min_allocator > A; + std::multimap m(A{}); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.get_allocator() == A()); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp index 73e8f24ff485..8c658d4f61aa 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::multimap C; typedef C::value_type V; C m = {{20, 1}}; @@ -46,5 +49,37 @@ int main() assert(*++i == V(3, 1)); assert(*++i == V(3, 1.5)); assert(*++i == V(3, 2)); + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> C; + typedef C::value_type V; + C m = {{20, 1}}; + m = + { + {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }; + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + C::const_iterator i = m.cbegin(); + assert(*i == V(1, 1)); + assert(*++i == V(1, 1.5)); + assert(*++i == V(1, 2)); + assert(*++i == V(2, 1)); + assert(*++i == V(2, 1.5)); + assert(*++i == V(2, 2)); + assert(*++i == V(3, 1)); + assert(*++i == V(3, 1.5)); + assert(*++i == V(3, 2)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/compare.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/compare.pass.cpp index 594db420db5f..99265ef72f80 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/compare.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/compare.pass.cpp @@ -17,12 +17,24 @@ #include #include "../../../test_compare.h" +#include "../../../min_allocator.h" int main() { + { typedef test_compare > C; std::multimap m(C(3)); assert(m.empty()); assert(m.begin() == m.end()); assert(m.key_comp() == C(3)); + } +#if __cplusplus >= 201103L + { + typedef test_compare > C; + std::multimap>> m(C(3)); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.key_comp() == C(3)); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp index 93546838b752..864a54299745 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp @@ -18,9 +18,11 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { + { typedef test_compare > C; typedef test_allocator > A; std::multimap m(C(4), A(5)); @@ -28,4 +30,16 @@ int main() assert(m.begin() == m.end()); assert(m.key_comp() == C(4)); assert(m.get_allocator() == A(5)); + } +#if __cplusplus >= 201103L + { + typedef test_compare > C; + typedef min_allocator > A; + std::multimap m(C(4), A()); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.key_comp() == C(4)); + assert(m.get_allocator() == A()); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/copy.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/copy.pass.cpp index b995b6eb8c15..65a1e921a476 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/copy.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/copy.pass.cpp @@ -18,6 +18,7 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -73,4 +74,31 @@ int main() assert(mo.key_comp() == C(5)); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare > C; + typedef min_allocator A; + std::multimap mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::multimap m = mo; + assert(m == mo); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp index bbbc397533d4..a9cba17de93c 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp @@ -18,9 +18,11 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { + { typedef std::pair V; V ar[] = { @@ -44,4 +46,32 @@ int main() assert(mo.get_allocator() == A(7)); assert(mo.key_comp() == C(5)); + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare > C; + typedef min_allocator A; + std::multimap mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::multimap m(mo, A()); + assert(m == mo); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp index 9b698035124c..533338c9683d 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp @@ -18,6 +18,7 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -73,4 +74,32 @@ int main() assert(mo.get_allocator() == A(2)); assert(mo.key_comp() == C(5)); } +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare > C; + typedef min_allocator A; + std::multimap mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::multimap m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A()); + m = mo; + assert(m == mo); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/default.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/default.pass.cpp index d2e3f60483b5..ca8225f37384 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/default.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/default.pass.cpp @@ -16,9 +16,20 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { std::multimap m; assert(m.empty()); assert(m.begin() == m.end()); + } +#if __cplusplus >= 201103L + { + std::multimap, min_allocator>> m; + assert(m.empty()); + assert(m.begin() == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp index 7683506f6630..139052c57304 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::multimap C; typedef C::value_type V; C m = @@ -45,5 +48,36 @@ int main() assert(*++i == V(3, 1)); assert(*++i == V(3, 1.5)); assert(*++i == V(3, 2)); + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> C; + typedef C::value_type V; + C m = + { + {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }; + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + C::const_iterator i = m.cbegin(); + assert(*i == V(1, 1)); + assert(*++i == V(1, 1.5)); + assert(*++i == V(1, 2)); + assert(*++i == V(2, 1)); + assert(*++i == V(2, 1.5)); + assert(*++i == V(2, 2)); + assert(*++i == V(3, 1)); + assert(*++i == V(3, 1.5)); + assert(*++i == V(3, 2)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp index 6d7f546ea410..f2545c0cbc16 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp @@ -16,10 +16,12 @@ #include #include #include "../../../test_compare.h" +#include "../../../min_allocator.h" int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef test_compare > Cmp; typedef std::multimap C; typedef C::value_type V; @@ -50,5 +52,40 @@ int main() assert(*++i == V(3, 1.5)); assert(*++i == V(3, 2)); assert(m.key_comp() == Cmp(4)); + } +#if __cplusplus >= 201103L + { + typedef test_compare > Cmp; + typedef std::multimap>> C; + typedef C::value_type V; + C m( + { + {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }, + Cmp(4) + ); + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + C::const_iterator i = m.cbegin(); + assert(*i == V(1, 1)); + assert(*++i == V(1, 1.5)); + assert(*++i == V(1, 2)); + assert(*++i == V(2, 1)); + assert(*++i == V(2, 1.5)); + assert(*++i == V(2, 2)); + assert(*++i == V(3, 1)); + assert(*++i == V(3, 1.5)); + assert(*++i == V(3, 2)); + assert(m.key_comp() == Cmp(4)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp index 47b48f1ef800..3f4073be082a 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp @@ -17,10 +17,12 @@ #include #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef test_compare > Cmp; typedef test_allocator > A; typedef std::multimap C; @@ -53,5 +55,42 @@ int main() assert(*++i == V(3, 2)); assert(m.key_comp() == Cmp(4)); assert(m.get_allocator() == A(5)); + } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if __cplusplus >= 201103L + { + typedef test_compare > Cmp; + typedef min_allocator > A; + typedef std::multimap C; + typedef C::value_type V; + C m( + { + {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }, + Cmp(4), A() + ); + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + C::const_iterator i = m.cbegin(); + assert(*i == V(1, 1)); + assert(*++i == V(1, 1.5)); + assert(*++i == V(1, 2)); + assert(*++i == V(2, 1)); + assert(*++i == V(2, 1.5)); + assert(*++i == V(2, 2)); + assert(*++i == V(3, 1)); + assert(*++i == V(3, 1.5)); + assert(*++i == V(3, 2)); + assert(m.key_comp() == Cmp(4)); + assert(m.get_allocator() == A()); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp index 00556ebcbf0d..3095cb56f337 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp @@ -17,8 +17,11 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { typedef std::pair V; V ar[] = { @@ -44,4 +47,34 @@ int main() assert(*next(m.begin(), 6) == V(3, 1)); assert(*next(m.begin(), 7) == V(3, 1.5)); assert(*next(m.begin(), 8) == V(3, 2)); + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + std::multimap, min_allocator> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(1, 1.5)); + assert(*next(m.begin(), 2) == V(1, 2)); + assert(*next(m.begin(), 3) == V(2, 1)); + assert(*next(m.begin(), 4) == V(2, 1.5)); + assert(*next(m.begin(), 5) == V(2, 2)); + assert(*next(m.begin(), 6) == V(3, 1)); + assert(*next(m.begin(), 7) == V(3, 1.5)); + assert(*next(m.begin(), 8) == V(3, 2)); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp index 57f879615f69..267edc210617 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp @@ -19,9 +19,11 @@ #include #include "../../../test_compare.h" +#include "../../../min_allocator.h" int main() { + { typedef std::pair V; V ar[] = { @@ -49,4 +51,36 @@ int main() assert(*next(m.begin(), 6) == V(3, 1)); assert(*next(m.begin(), 7) == V(3, 1.5)); assert(*next(m.begin(), 8) == V(3, 2)); + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare > C; + std::multimap> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5)); + assert(m.key_comp() == C(5)); + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(1, 1.5)); + assert(*next(m.begin(), 2) == V(1, 2)); + assert(*next(m.begin(), 3) == V(2, 1)); + assert(*next(m.begin(), 4) == V(2, 1.5)); + assert(*next(m.begin(), 5) == V(2, 2)); + assert(*next(m.begin(), 6) == V(3, 1)); + assert(*next(m.begin(), 7) == V(3, 1.5)); + assert(*next(m.begin(), 8) == V(3, 2)); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp index c7b0d97a5aa6..883f64c8e93d 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp @@ -20,9 +20,11 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { + { typedef std::pair V; V ar[] = { @@ -52,4 +54,38 @@ int main() assert(*next(m.begin(), 6) == V(3, 1)); assert(*next(m.begin(), 7) == V(3, 1.5)); assert(*next(m.begin(), 8) == V(3, 2)); + } +#if __cplusplus >= 201103L + { + typedef std::pair V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare > C; + typedef min_allocator A; + std::multimap m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(1, 1.5)); + assert(*next(m.begin(), 2) == V(1, 2)); + assert(*next(m.begin(), 3) == V(2, 1)); + assert(*next(m.begin(), 4) == V(2, 1.5)); + assert(*next(m.begin(), 5) == V(2, 2)); + assert(*next(m.begin(), 6) == V(3, 1)); + assert(*next(m.begin(), 7) == V(3, 1.5)); + assert(*next(m.begin(), 8) == V(3, 2)); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/move.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/move.pass.cpp index 815fc55676c3..d6e835ca4772 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/move.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/move.pass.cpp @@ -18,6 +18,7 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -74,5 +75,58 @@ int main() assert(mo.size() == 0); assert(distance(mo.begin(), mo.end()) == 0); } +#if __cplusplus >= 201103L + { + typedef test_compare > C; + typedef min_allocator A; + std::multimap mo(C(5), A()); + std::multimap m = std::move(mo); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 0); + assert(distance(m.begin(), m.end()) == 0); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 0); + assert(distance(mo.begin(), mo.end()) == 0); + } + { + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare > C; + typedef min_allocator A; + std::multimap mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::multimap m = std::move(mo); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(1, 1.5)); + assert(*next(m.begin(), 2) == V(1, 2)); + assert(*next(m.begin(), 3) == V(2, 1)); + assert(*next(m.begin(), 4) == V(2, 1.5)); + assert(*next(m.begin(), 5) == V(2, 2)); + assert(*next(m.begin(), 6) == V(3, 1)); + assert(*next(m.begin(), 7) == V(3, 1.5)); + assert(*next(m.begin(), 8) == V(3, 2)); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 0); + assert(distance(mo.begin(), mo.end()) == 0); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp index ed5eb24abcbf..c807b4ff558f 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp @@ -19,6 +19,7 @@ #include "../../../MoveOnly.h" #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -140,5 +141,46 @@ int main() assert(m3.key_comp() == C(5)); assert(m1.empty()); } +#if __cplusplus >= 201103L + { + typedef std::pair V; + typedef std::pair VC; + typedef test_compare > C; + typedef min_allocator A; + typedef std::multimap M; + typedef std::move_iterator I; + V a1[] = + { + V(1, 1), + V(1, 2), + V(1, 3), + V(2, 1), + V(2, 2), + V(2, 3), + V(3, 1), + V(3, 2), + V(3, 3) + }; + M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A()); + V a2[] = + { + V(1, 1), + V(1, 2), + V(1, 3), + V(2, 1), + V(2, 2), + V(2, 3), + V(3, 1), + V(3, 2), + V(3, 3) + }; + M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A()); + M m3(std::move(m1), A()); + assert(m3 == m2); + assert(m3.get_allocator() == A()); + assert(m3.key_comp() == C(5)); + assert(m1.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/move_assign.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/move_assign.pass.cpp index 4a1e2e95fcdf..0aa7c185784f 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/move_assign.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/move_assign.pass.cpp @@ -19,6 +19,7 @@ #include "../../../MoveOnly.h" #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -143,5 +144,47 @@ int main() assert(m3.key_comp() == C(5)); assert(m1.empty()); } +#if __cplusplus >= 201103L + { + typedef std::pair V; + typedef std::pair VC; + typedef test_compare > C; + typedef min_allocator A; + typedef std::multimap M; + typedef std::move_iterator I; + V a1[] = + { + V(1, 1), + V(1, 2), + V(1, 3), + V(2, 1), + V(2, 2), + V(2, 3), + V(3, 1), + V(3, 2), + V(3, 3) + }; + M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A()); + V a2[] = + { + V(1, 1), + V(1, 2), + V(1, 3), + V(2, 1), + V(2, 2), + V(2, 3), + V(3, 1), + V(3, 2), + V(3, 3) + }; + M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A()); + M m3(C(3), A()); + m3 = std::move(m1); + assert(m3 == m2); + assert(m3.get_allocator() == A()); + assert(m3.key_comp() == C(5)); + assert(m1.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/multimap/multimap.modifiers/clear.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.modifiers/clear.pass.cpp index e10b06a0c264..4864ec1141bd 100644 --- a/libcxx/test/containers/associative/multimap/multimap.modifiers/clear.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.modifiers/clear.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -37,4 +39,25 @@ int main() m.clear(); assert(m.size() == 0); } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + typedef std::pair P; + P ar[] = + { + P(1, 1.5), + P(2, 2.5), + P(3, 3.5), + P(4, 4.5), + P(5, 5.5), + P(6, 6.5), + P(7, 7.5), + P(8, 8.5), + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + m.clear(); + assert(m.size() == 0); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp index 22406d8fb522..c91909e72247 100644 --- a/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp @@ -19,6 +19,7 @@ #include "../../../Emplaceable.h" #include "../../../DefaultOnly.h" +#include "../../../min_allocator.h" int main() { @@ -80,5 +81,64 @@ int main() assert(m.begin()->first == 2); assert(m.begin()->second == 3.5); } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + typedef M::iterator R; + M m; + assert(DefaultOnly::count == 0); + R r = m.emplace(); + assert(r == m.begin()); + assert(m.size() == 1); + assert(m.begin()->first == 0); + assert(m.begin()->second == DefaultOnly()); + assert(DefaultOnly::count == 1); + r = m.emplace(1); + assert(r == next(m.begin())); + assert(m.size() == 2); + assert(next(m.begin())->first == 1); + assert(next(m.begin())->second == DefaultOnly()); + assert(DefaultOnly::count == 2); + r = m.emplace(1); + assert(r == next(m.begin(), 2)); + assert(m.size() == 3); + assert(next(m.begin(), 2)->first == 1); + assert(next(m.begin(), 2)->second == DefaultOnly()); + assert(DefaultOnly::count == 3); + } + assert(DefaultOnly::count == 0); + { + typedef std::multimap, min_allocator>> M; + typedef M::iterator R; + M m; + R r = m.emplace(2); + assert(r == m.begin()); + assert(m.size() == 1); + assert(m.begin()->first == 2); + assert(m.begin()->second == Emplaceable()); + r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), + std::forward_as_tuple(2, 3.5)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(m.begin()->first == 1); + assert(m.begin()->second == Emplaceable(2, 3.5)); + r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), + std::forward_as_tuple(3, 3.5)); + assert(r == next(m.begin())); + assert(m.size() == 3); + assert(r->first == 1); + assert(r->second == Emplaceable(3, 3.5)); + } + { + typedef std::multimap, min_allocator>> M; + typedef M::iterator R; + M m; + R r = m.emplace(M::value_type(2, 3.5)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(m.begin()->first == 2); + assert(m.begin()->second == 3.5); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp index 4c3e468d5948..8dc3195b7110 100644 --- a/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp @@ -19,6 +19,7 @@ #include "../../../Emplaceable.h" #include "../../../DefaultOnly.h" +#include "../../../min_allocator.h" int main() { @@ -82,5 +83,66 @@ int main() assert(m.begin()->first == 2); assert(m.begin()->second == 3.5); } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + typedef M::iterator R; + M m; + assert(DefaultOnly::count == 0); + R r = m.emplace_hint(m.cend()); + assert(r == m.begin()); + assert(m.size() == 1); + assert(m.begin()->first == 0); + assert(m.begin()->second == DefaultOnly()); + assert(DefaultOnly::count == 1); + r = m.emplace_hint(m.cend(), 1); + assert(r == next(m.begin())); + assert(m.size() == 2); + assert(next(m.begin())->first == 1); + assert(next(m.begin())->second == DefaultOnly()); + assert(DefaultOnly::count == 2); + r = m.emplace_hint(m.cend(), 1); + assert(r == next(m.begin(), 2)); + assert(m.size() == 3); + assert(next(m.begin(), 2)->first == 1); + assert(next(m.begin(), 2)->second == DefaultOnly()); + assert(DefaultOnly::count == 3); + } + assert(DefaultOnly::count == 0); + { + typedef std::multimap, min_allocator>> M; + typedef M::iterator R; + M m; + R r = m.emplace_hint(m.cend(), 2); + assert(r == m.begin()); + assert(m.size() == 1); + assert(m.begin()->first == 2); + assert(m.begin()->second == Emplaceable()); + r = m.emplace_hint(m.cbegin(), std::piecewise_construct, + std::forward_as_tuple(1), + std::forward_as_tuple(2, 3.5)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(m.begin()->first == 1); + assert(m.begin()->second == Emplaceable(2, 3.5)); + r = m.emplace_hint(m.cbegin(), std::piecewise_construct, + std::forward_as_tuple(1), + std::forward_as_tuple(3, 3.5)); + assert(r == m.begin()); + assert(m.size() == 3); + assert(r->first == 1); + assert(r->second == Emplaceable(3, 3.5)); + } + { + typedef std::multimap, min_allocator>> M; + typedef M::iterator R; + M m; + R r = m.emplace_hint(m.cend(), M::value_type(2, 3.5)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(m.begin()->first == 2); + assert(m.begin()->second == 3.5); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp index 794d31176aa5..d2979b1eecc7 100644 --- a/libcxx/test/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -145,4 +147,133 @@ int main() assert(i == m.begin()); assert(i == m.end()); } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + typedef std::pair P; + typedef M::iterator I; + P ar[] = + { + P(1, 1), + P(1, 1.5), + P(1, 2), + P(2, 1), + P(2, 1.5), + P(2, 2), + P(3, 1), + P(3, 1.5), + P(3, 2), + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 9); + I i = m.erase(next(m.cbegin(), 3)); + assert(m.size() == 8); + assert(i == next(m.begin(), 3)); + assert(m.begin()->first == 1); + assert(m.begin()->second == 1); + assert(next(m.begin())->first == 1); + assert(next(m.begin())->second == 1.5); + assert(next(m.begin(), 2)->first == 1); + assert(next(m.begin(), 2)->second == 2); + assert(next(m.begin(), 3)->first == 2); + assert(next(m.begin(), 3)->second == 1.5); + assert(next(m.begin(), 4)->first == 2); + assert(next(m.begin(), 4)->second == 2); + assert(next(m.begin(), 5)->first == 3); + assert(next(m.begin(), 5)->second == 1); + assert(next(m.begin(), 6)->first == 3); + assert(next(m.begin(), 6)->second == 1.5); + assert(next(m.begin(), 7)->first == 3); + assert(next(m.begin(), 7)->second == 2); + + i = m.erase(next(m.cbegin(), 0)); + assert(m.size() == 7); + assert(i == m.begin()); + assert(next(m.begin(), 0)->first == 1); + assert(next(m.begin(), 0)->second == 1.5); + assert(next(m.begin(), 1)->first == 1); + assert(next(m.begin(), 1)->second == 2); + assert(next(m.begin(), 2)->first == 2); + assert(next(m.begin(), 2)->second == 1.5); + assert(next(m.begin(), 3)->first == 2); + assert(next(m.begin(), 3)->second == 2); + assert(next(m.begin(), 4)->first == 3); + assert(next(m.begin(), 4)->second == 1); + assert(next(m.begin(), 5)->first == 3); + assert(next(m.begin(), 5)->second == 1.5); + assert(next(m.begin(), 6)->first == 3); + assert(next(m.begin(), 6)->second == 2); + + i = m.erase(next(m.cbegin(), 5)); + assert(m.size() == 6); + assert(i == prev(m.end())); + assert(next(m.begin(), 0)->first == 1); + assert(next(m.begin(), 0)->second == 1.5); + assert(next(m.begin(), 1)->first == 1); + assert(next(m.begin(), 1)->second == 2); + assert(next(m.begin(), 2)->first == 2); + assert(next(m.begin(), 2)->second == 1.5); + assert(next(m.begin(), 3)->first == 2); + assert(next(m.begin(), 3)->second == 2); + assert(next(m.begin(), 4)->first == 3); + assert(next(m.begin(), 4)->second == 1); + assert(next(m.begin(), 5)->first == 3); + assert(next(m.begin(), 5)->second == 2); + + i = m.erase(next(m.cbegin(), 1)); + assert(m.size() == 5); + assert(i == next(m.begin())); + assert(next(m.begin(), 0)->first == 1); + assert(next(m.begin(), 0)->second == 1.5); + assert(next(m.begin(), 1)->first == 2); + assert(next(m.begin(), 1)->second == 1.5); + assert(next(m.begin(), 2)->first == 2); + assert(next(m.begin(), 2)->second == 2); + assert(next(m.begin(), 3)->first == 3); + assert(next(m.begin(), 3)->second == 1); + assert(next(m.begin(), 4)->first == 3); + assert(next(m.begin(), 4)->second == 2); + + i = m.erase(next(m.cbegin(), 2)); + assert(m.size() == 4); + assert(i == next(m.begin(), 2)); + assert(next(m.begin(), 0)->first == 1); + assert(next(m.begin(), 0)->second == 1.5); + assert(next(m.begin(), 1)->first == 2); + assert(next(m.begin(), 1)->second == 1.5); + assert(next(m.begin(), 2)->first == 3); + assert(next(m.begin(), 2)->second == 1); + assert(next(m.begin(), 3)->first == 3); + assert(next(m.begin(), 3)->second == 2); + + i = m.erase(next(m.cbegin(), 2)); + assert(m.size() == 3); + assert(i == next(m.begin(), 2)); + assert(next(m.begin(), 0)->first == 1); + assert(next(m.begin(), 0)->second == 1.5); + assert(next(m.begin(), 1)->first == 2); + assert(next(m.begin(), 1)->second == 1.5); + assert(next(m.begin(), 2)->first == 3); + assert(next(m.begin(), 2)->second == 2); + + i = m.erase(next(m.cbegin(), 0)); + assert(m.size() == 2); + assert(i == next(m.begin(), 0)); + assert(next(m.begin(), 0)->first == 2); + assert(next(m.begin(), 0)->second == 1.5); + assert(next(m.begin(), 1)->first == 3); + assert(next(m.begin(), 1)->second == 2); + + i = m.erase(next(m.cbegin(), 1)); + assert(m.size() == 1); + assert(i == m.end()); + assert(next(m.begin(), 0)->first == 2); + assert(next(m.begin(), 0)->second == 1.5); + + i = m.erase(m.cbegin()); + assert(m.size() == 0); + assert(i == m.begin()); + assert(i == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp index 954c56db5093..be1ab6f8d232 100644 --- a/libcxx/test/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -84,4 +86,72 @@ int main() assert(i == m.begin()); assert(i == m.end()); } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + typedef std::pair P; + typedef M::iterator I; + P ar[] = + { + P(1, 1.5), + P(2, 2.5), + P(3, 3.5), + P(4, 4.5), + P(5, 5.5), + P(6, 6.5), + P(7, 7.5), + P(8, 8.5), + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + I i = m.erase(m.cbegin(), m.cbegin()); + assert(m.size() == 8); + assert(i == m.begin()); + assert(m.begin()->first == 1); + assert(m.begin()->second == 1.5); + assert(next(m.begin())->first == 2); + assert(next(m.begin())->second == 2.5); + assert(next(m.begin(), 2)->first == 3); + assert(next(m.begin(), 2)->second == 3.5); + assert(next(m.begin(), 3)->first == 4); + assert(next(m.begin(), 3)->second == 4.5); + assert(next(m.begin(), 4)->first == 5); + assert(next(m.begin(), 4)->second == 5.5); + assert(next(m.begin(), 5)->first == 6); + assert(next(m.begin(), 5)->second == 6.5); + assert(next(m.begin(), 6)->first == 7); + assert(next(m.begin(), 6)->second == 7.5); + assert(next(m.begin(), 7)->first == 8); + assert(next(m.begin(), 7)->second == 8.5); + + i = m.erase(m.cbegin(), next(m.cbegin(), 2)); + assert(m.size() == 6); + assert(i == m.begin()); + assert(next(m.begin(), 0)->first == 3); + assert(next(m.begin(), 0)->second == 3.5); + assert(next(m.begin(), 1)->first == 4); + assert(next(m.begin(), 1)->second == 4.5); + assert(next(m.begin(), 2)->first == 5); + assert(next(m.begin(), 2)->second == 5.5); + assert(next(m.begin(), 3)->first == 6); + assert(next(m.begin(), 3)->second == 6.5); + assert(next(m.begin(), 4)->first == 7); + assert(next(m.begin(), 4)->second == 7.5); + assert(next(m.begin(), 5)->first == 8); + assert(next(m.begin(), 5)->second == 8.5); + + i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6)); + assert(m.size() == 2); + assert(i == next(m.begin(), 2)); + assert(next(m.begin(), 0)->first == 3); + assert(next(m.begin(), 0)->second == 3.5); + assert(next(m.begin(), 1)->first == 4); + assert(next(m.begin(), 1)->second == 4.5); + + i = m.erase(m.cbegin(), m.cend()); + assert(m.size() == 0); + assert(i == m.begin()); + assert(i == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp index cdf5b9db0238..c5dd6fbdcc7e 100644 --- a/libcxx/test/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -81,4 +83,69 @@ int main() assert(m.size() == 0); assert(i == 3); } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + typedef std::pair P; + typedef M::size_type I; + P ar[] = + { + P(1, 1), + P(1, 1.5), + P(1, 2), + P(2, 1), + P(2, 1.5), + P(2, 2), + P(3, 1), + P(3, 1.5), + P(3, 2), + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 9); + I i = m.erase(2); + assert(m.size() == 6); + assert(i == 3); + assert(next(m.begin(), 0)->first == 1); + assert(next(m.begin(), 0)->second == 1); + assert(next(m.begin(), 1)->first == 1); + assert(next(m.begin(), 1)->second == 1.5); + assert(next(m.begin(), 2)->first == 1); + assert(next(m.begin(), 2)->second == 2); + assert(next(m.begin(), 3)->first == 3); + assert(next(m.begin(), 3)->second == 1); + assert(next(m.begin(), 4)->first == 3); + assert(next(m.begin(), 4)->second == 1.5); + assert(next(m.begin(), 5)->first == 3); + assert(next(m.begin(), 5)->second == 2); + + i = m.erase(2); + assert(m.size() == 6); + assert(i == 0); + assert(next(m.begin(), 0)->first == 1); + assert(next(m.begin(), 0)->second == 1); + assert(next(m.begin(), 1)->first == 1); + assert(next(m.begin(), 1)->second == 1.5); + assert(next(m.begin(), 2)->first == 1); + assert(next(m.begin(), 2)->second == 2); + assert(next(m.begin(), 3)->first == 3); + assert(next(m.begin(), 3)->second == 1); + assert(next(m.begin(), 4)->first == 3); + assert(next(m.begin(), 4)->second == 1.5); + assert(next(m.begin(), 5)->first == 3); + assert(next(m.begin(), 5)->second == 2); + + i = m.erase(3); + assert(m.size() == 3); + assert(next(m.begin(), 0)->first == 1); + assert(next(m.begin(), 0)->second == 1); + assert(next(m.begin(), 1)->first == 1); + assert(next(m.begin(), 1)->second == 1.5); + assert(next(m.begin(), 2)->first == 1); + assert(next(m.begin(), 2)->second == 2); + + i = m.erase(1); + assert(m.size() == 0); + assert(i == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp index 4ad2704be0af..c23d821e0bb2 100644 --- a/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -46,4 +48,34 @@ int main() assert(r->first == 3); assert(r->second == 3.5); } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + typedef M::iterator R; + M m; + R r = m.insert(M::value_type(2, 2.5)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2.5); + + r = m.insert(M::value_type(1, 1.5)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1.5); + + r = m.insert(M::value_type(3, 3.5)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3.5); + + r = m.insert(M::value_type(3, 3.5)); + assert(r == prev(m.end())); + assert(m.size() == 4); + assert(r->first == 3); + assert(r->second == 3.5); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp index 26a9cb8cfd90..8fc080d013f5 100644 --- a/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::multimap C; typedef C::value_type V; C m = @@ -49,5 +52,40 @@ int main() assert(*++i == V(3, 1)); assert(*++i == V(3, 2)); assert(*++i == V(3, 1.5)); + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> C; + typedef C::value_type V; + C m = + { + {1, 1}, + {1, 2}, + {2, 1}, + {2, 2}, + {3, 1}, + {3, 2} + }; + m.insert( + { + {1, 1.5}, + {2, 1.5}, + {3, 1.5}, + } + ); + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + C::const_iterator i = m.cbegin(); + assert(*i == V(1, 1)); + assert(*++i == V(1, 2)); + assert(*++i == V(1, 1.5)); + assert(*++i == V(2, 1)); + assert(*++i == V(2, 2)); + assert(*++i == V(2, 1.5)); + assert(*++i == V(3, 1)); + assert(*++i == V(3, 2)); + assert(*++i == V(3, 1.5)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp index ebe49012cd05..0c8e91687315 100644 --- a/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -46,4 +48,34 @@ int main() assert(r->first == 3); assert(r->second == 4.5); } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + typedef M::iterator R; + M m; + R r = m.insert(m.end(), M::value_type(2, 2.5)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2.5); + + r = m.insert(m.end(), M::value_type(1, 1.5)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1.5); + + r = m.insert(m.end(), M::value_type(3, 3.5)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3.5); + + r = m.insert(prev(m.end()), M::value_type(3, 4.5)); + assert(r == prev(m.end(), 2)); + assert(m.size() == 4); + assert(r->first == 3); + assert(r->second == 4.5); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp index fcd4cee8f9bc..6e3d2f26bc34 100644 --- a/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp @@ -18,6 +18,7 @@ #include #include "test_iterators.h" +#include "../../../min_allocator.h" int main() { @@ -58,4 +59,43 @@ int main() assert(next(m.begin(), 8)->first == 3); assert(next(m.begin(), 8)->second == 2); } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + typedef std::pair P; + P ar[] = + { + P(1, 1), + P(1, 1.5), + P(1, 2), + P(2, 1), + P(2, 1.5), + P(2, 2), + P(3, 1), + P(3, 1.5), + P(3, 2), + }; + M m; + m.insert(input_iterator(ar), input_iterator(ar + sizeof(ar)/sizeof(ar[0]))); + assert(m.size() == 9); + assert(m.begin()->first == 1); + assert(m.begin()->second == 1); + assert(next(m.begin())->first == 1); + assert(next(m.begin())->second == 1.5); + assert(next(m.begin(), 2)->first == 1); + assert(next(m.begin(), 2)->second == 2); + assert(next(m.begin(), 3)->first == 2); + assert(next(m.begin(), 3)->second == 1); + assert(next(m.begin(), 4)->first == 2); + assert(next(m.begin(), 4)->second == 1.5); + assert(next(m.begin(), 5)->first == 2); + assert(next(m.begin(), 5)->second == 2); + assert(next(m.begin(), 6)->first == 3); + assert(next(m.begin(), 6)->second == 1); + assert(next(m.begin(), 7)->first == 3); + assert(next(m.begin(), 7)->second == 1.5); + assert(next(m.begin(), 8)->first == 3); + assert(next(m.begin(), 8)->second == 2); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp index 15993cbfd31a..efc99e1e7620 100644 --- a/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp @@ -18,6 +18,7 @@ #include #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -51,5 +52,36 @@ int main() assert(r->first == 3); assert(r->second == 2); } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + typedef std::pair P; + typedef M::iterator R; + M m; + R r = m.insert(m.cend(), P(2, 2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2); + + r = m.insert(m.cend(), P(1, 1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1); + + r = m.insert(m.cend(), P(3, 3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3); + + r = m.insert(m.cend(), P(3, 2)); + assert(r == prev(m.end())); + assert(m.size() == 4); + assert(r->first == 3); + assert(r->second == 2); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp index 285881cac71c..1678c9de89e9 100644 --- a/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp @@ -18,6 +18,7 @@ #include #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -50,5 +51,35 @@ int main() assert(r->first == 3); assert(r->second == 3); } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + typedef M::iterator R; + M m; + R r = m.insert(M::value_type(2, 2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2); + + r = m.insert(M::value_type(1, 1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1); + + r = m.insert(M::value_type(3, 3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3); + + r = m.insert(M::value_type(3, 3)); + assert(r == prev(m.end())); + assert(m.size() == 4); + assert(r->first == 3); + assert(r->second == 3); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/multimap/multimap.ops/count.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.ops/count.pass.cpp index e707cd700669..b0e4c58873ce 100644 --- a/libcxx/test/containers/associative/multimap/multimap.ops/count.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.ops/count.pass.cpp @@ -16,9 +16,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { typedef std::pair V; + { typedef std::multimap M; { typedef M::size_type R; @@ -50,4 +53,40 @@ int main() r = m.count(10); assert(r == 0); } + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + { + typedef M::size_type R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.count(4); + assert(r == 0); + r = m.count(5); + assert(r == 3); + r = m.count(6); + assert(r == 0); + r = m.count(7); + assert(r == 3); + r = m.count(8); + assert(r == 0); + r = m.count(9); + assert(r == 3); + r = m.count(10); + assert(r == 0); + } + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.ops/equal_range.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.ops/equal_range.pass.cpp index 73f392cad105..030d4681ded0 100644 --- a/libcxx/test/containers/associative/multimap/multimap.ops/equal_range.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.ops/equal_range.pass.cpp @@ -17,9 +17,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { typedef std::pair V; + { typedef std::multimap M; { typedef std::pair R; @@ -95,4 +98,84 @@ int main() assert(r.first == m.end()); assert(r.second == m.end()); } + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + { + typedef std::pair R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.equal_range(4); + assert(r.first == m.begin()); + assert(r.second == m.begin()); + r = m.equal_range(5); + assert(r.first == m.begin()); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(6); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(7); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(8); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(9); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 9)); + r = m.equal_range(10); + assert(r.first == m.end()); + assert(r.second == m.end()); + } + { + typedef std::pair R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.equal_range(4); + assert(r.first == m.begin()); + assert(r.second == m.begin()); + r = m.equal_range(5); + assert(r.first == m.begin()); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(6); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(7); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(8); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(9); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 9)); + r = m.equal_range(10); + assert(r.first == m.end()); + assert(r.second == m.end()); + } + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.ops/find.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.ops/find.pass.cpp index fe7e34f5fb2b..aa22d3971fd4 100644 --- a/libcxx/test/containers/associative/multimap/multimap.ops/find.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.ops/find.pass.cpp @@ -17,9 +17,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { typedef std::pair V; + { typedef std::multimap M; { typedef M::iterator R; @@ -77,4 +80,66 @@ int main() r = m.find(10); assert(r == m.end()); } + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + { + typedef M::iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == m.end()); + r = m.find(7); + assert(r == next(m.begin(), 3)); + r = m.find(8); + assert(r == m.end()); + r = m.find(9); + assert(r == next(m.begin(), 6)); + r = m.find(10); + assert(r == m.end()); + } + { + typedef M::const_iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == m.end()); + r = m.find(7); + assert(r == next(m.begin(), 3)); + r = m.find(8); + assert(r == m.end()); + r = m.find(9); + assert(r == next(m.begin(), 6)); + r = m.find(10); + assert(r == m.end()); + } + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp index fe682f18297e..508b077b2eed 100644 --- a/libcxx/test/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp @@ -17,9 +17,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { typedef std::pair V; + { typedef std::multimap M; { typedef M::iterator R; @@ -81,4 +84,70 @@ int main() r = m.lower_bound(10); assert(r == m.end()); } + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + { + typedef M::iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(4); + assert(r == m.begin()); + r = m.lower_bound(5); + assert(r == m.begin()); + r = m.lower_bound(6); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(7); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(9); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(10); + assert(r == m.end()); + } + { + typedef M::const_iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(4); + assert(r == m.begin()); + r = m.lower_bound(5); + assert(r == m.begin()); + r = m.lower_bound(6); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(7); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(9); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(10); + assert(r == m.end()); + } + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp index 3d6bd88a9f2e..6f40c20d997e 100644 --- a/libcxx/test/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp @@ -17,9 +17,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { typedef std::pair V; + { typedef std::multimap M; { typedef M::iterator R; @@ -81,4 +84,70 @@ int main() r = m.upper_bound(10); assert(r == m.end()); } + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + { + typedef M::iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(4); + assert(r == m.begin()); + r = m.upper_bound(5); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 9)); + r = m.upper_bound(10); + assert(r == m.end()); + } + { + typedef M::const_iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(4); + assert(r == m.begin()); + r = m.upper_bound(5); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 9)); + r = m.upper_bound(10); + assert(r == m.end()); + } + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.special/member_swap.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.special/member_swap.pass.cpp index 05d1260319c7..1e1ab2335abf 100644 --- a/libcxx/test/containers/associative/multimap/multimap.special/member_swap.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.special/member_swap.pass.cpp @@ -16,9 +16,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { typedef std::pair V; + { typedef std::multimap M; { V ar1[] = @@ -104,4 +107,94 @@ int main() assert(m1 == m2_save); assert(m2 == m1_save); } + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + { + V ar1[] = + { + }; + V ar2[] = + { + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + }; + V ar2[] = + { + V(5, 5), + V(6, 6), + V(7, 7), + V(8, 8), + V(9, 9), + V(10, 10), + V(11, 11), + V(12, 12) + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + V(1, 1), + V(2, 2), + V(3, 3), + V(4, 4) + }; + V ar2[] = + { + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + V(1, 1), + V(2, 2), + V(3, 3), + V(4, 4) + }; + V ar2[] = + { + V(5, 5), + V(6, 6), + V(7, 7), + V(8, 8), + V(9, 9), + V(10, 10), + V(11, 11), + V(12, 12) + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp index 390340f17995..6f5b92fe1fec 100644 --- a/libcxx/test/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp @@ -19,10 +19,12 @@ #include #include "../../../test_allocator.h" #include "../../../test_compare.h" +#include "../../../min_allocator.h" int main() { typedef std::pair V; + { typedef std::multimap M; { V ar1[] = @@ -176,4 +178,128 @@ int main() assert(m2.key_comp() == C(1)); assert(m2.get_allocator() == A(1)); } + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + { + V ar1[] = + { + }; + V ar2[] = + { + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + swap(m1, m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + }; + V ar2[] = + { + V(5, 5), + V(6, 6), + V(7, 7), + V(8, 8), + V(9, 9), + V(10, 10), + V(11, 11), + V(12, 12) + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + swap(m1, m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + V(1, 1), + V(2, 2), + V(3, 3), + V(4, 4) + }; + V ar2[] = + { + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + swap(m1, m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + V(1, 1), + V(2, 2), + V(3, 3), + V(4, 4) + }; + V ar2[] = + { + V(5, 5), + V(6, 6), + V(7, 7), + V(8, 8), + V(9, 9), + V(10, 10), + V(11, 11), + V(12, 12) + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + swap(m1, m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + typedef min_allocator A; + typedef test_compare > C; + typedef std::multimap M; + V ar1[] = + { + V(1, 1), + V(2, 2), + V(3, 3), + V(4, 4) + }; + V ar2[] = + { + V(5, 5), + V(6, 6), + V(7, 7), + V(8, 8), + V(9, 9), + V(10, 10), + V(11, 11), + V(12, 12) + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A()); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A()); + M m1_save = m1; + M m2_save = m2; + swap(m1, m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + assert(m1.key_comp() == C(2)); + assert(m1.get_allocator() == A()); + assert(m2.key_comp() == C(1)); + assert(m2.get_allocator() == A()); + } + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/size.pass.cpp b/libcxx/test/containers/associative/multimap/size.pass.cpp index eb7b1c914aec..794c34a2846a 100644 --- a/libcxx/test/containers/associative/multimap/size.pass.cpp +++ b/libcxx/test/containers/associative/multimap/size.pass.cpp @@ -16,8 +16,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef std::multimap M; M m; assert(m.size() == 0); @@ -33,4 +36,24 @@ int main() assert(m.size() == 1); m.erase(m.begin()); assert(m.size() == 0); + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> M; + M m; + assert(m.size() == 0); + m.insert(M::value_type(2, 1.5)); + assert(m.size() == 1); + m.insert(M::value_type(1, 1.5)); + assert(m.size() == 2); + m.insert(M::value_type(3, 1.5)); + assert(m.size() == 3); + m.erase(m.begin()); + assert(m.size() == 2); + m.erase(m.begin()); + assert(m.size() == 1); + m.erase(m.begin()); + assert(m.size() == 0); + } +#endif } diff --git a/libcxx/test/containers/associative/multimap/types.pass.cpp b/libcxx/test/containers/associative/multimap/types.pass.cpp index 4bb724227477..2fe8fe0eabf5 100644 --- a/libcxx/test/containers/associative/multimap/types.pass.cpp +++ b/libcxx/test/containers/associative/multimap/types.pass.cpp @@ -32,8 +32,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { static_assert((std::is_same::key_type, int>::value), ""); static_assert((std::is_same::mapped_type, double>::value), ""); static_assert((std::is_same::value_type, std::pair >::value), ""); @@ -45,4 +48,20 @@ int main() static_assert((std::is_same::const_pointer, const std::pair*>::value), ""); static_assert((std::is_same::size_type, std::size_t>::value), ""); static_assert((std::is_same::difference_type, std::ptrdiff_t>::value), ""); + } +#if __cplusplus >= 201103L + { + static_assert((std::is_same, min_allocator>>::key_type, int>::value), ""); + static_assert((std::is_same, min_allocator>>::mapped_type, double>::value), ""); + static_assert((std::is_same, min_allocator>>::value_type, std::pair >::value), ""); + static_assert((std::is_same, min_allocator>>::key_compare, std::less >::value), ""); + static_assert((std::is_same, min_allocator>>::allocator_type, min_allocator > >::value), ""); + static_assert((std::is_same, min_allocator>>::reference, std::pair&>::value), ""); + static_assert((std::is_same, min_allocator>>::const_reference, const std::pair&>::value), ""); + static_assert((std::is_same, min_allocator>>::pointer, min_pointer>>::value), ""); + static_assert((std::is_same, min_allocator>>::const_pointer, min_pointer>>::value), ""); + static_assert((std::is_same, min_allocator>>::size_type, std::size_t>::value), ""); + static_assert((std::is_same, min_allocator>>::difference_type, std::ptrdiff_t>::value), ""); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/clear.pass.cpp b/libcxx/test/containers/associative/multiset/clear.pass.cpp index f91b74f03e07..f325a701abed 100644 --- a/libcxx/test/containers/associative/multiset/clear.pass.cpp +++ b/libcxx/test/containers/associative/multiset/clear.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -37,4 +39,25 @@ int main() m.clear(); assert(m.size() == 0); } +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> M; + typedef int V; + V ar[] = + { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + m.clear(); + assert(m.size() == 0); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/count.pass.cpp b/libcxx/test/containers/associative/multiset/count.pass.cpp index 726c80594caa..cba64301a335 100644 --- a/libcxx/test/containers/associative/multiset/count.pass.cpp +++ b/libcxx/test/containers/associative/multiset/count.pass.cpp @@ -16,8 +16,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int V; typedef std::multiset M; { @@ -50,4 +53,41 @@ int main() r = m.count(10); assert(r == 0); } + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::multiset, min_allocator> M; + { + typedef M::size_type R; + V ar[] = + { + 5, + 5, + 5, + 5, + 7, + 7, + 7, + 9, + 9 + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.count(4); + assert(r == 0); + r = m.count(5); + assert(r == 4); + r = m.count(6); + assert(r == 0); + r = m.count(7); + assert(r == 3); + r = m.count(8); + assert(r == 0); + r = m.count(9); + assert(r == 2); + r = m.count(10); + assert(r == 0); + } + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/emplace.pass.cpp b/libcxx/test/containers/associative/multiset/emplace.pass.cpp index 55f11fce2070..08ac42b1d130 100644 --- a/libcxx/test/containers/associative/multiset/emplace.pass.cpp +++ b/libcxx/test/containers/associative/multiset/emplace.pass.cpp @@ -19,6 +19,7 @@ #include "../../Emplaceable.h" #include "../../DefaultOnly.h" +#include "../../min_allocator.h" int main() { @@ -67,5 +68,16 @@ int main() assert(m.size() == 1); assert(*r == 2); } +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> M; + typedef M::iterator R; + M m; + R r = m.emplace(M::value_type(2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(*r == 2); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/multiset/emplace_hint.pass.cpp b/libcxx/test/containers/associative/multiset/emplace_hint.pass.cpp index 9e4befa71198..1510c0104778 100644 --- a/libcxx/test/containers/associative/multiset/emplace_hint.pass.cpp +++ b/libcxx/test/containers/associative/multiset/emplace_hint.pass.cpp @@ -19,6 +19,7 @@ #include "../../Emplaceable.h" #include "../../DefaultOnly.h" +#include "../../min_allocator.h" int main() { @@ -67,5 +68,16 @@ int main() assert(m.size() == 1); assert(*r == 2); } +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> M; + typedef M::iterator R; + M m; + R r = m.emplace_hint(m.cend(), M::value_type(2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(*r == 2); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/multiset/empty.pass.cpp b/libcxx/test/containers/associative/multiset/empty.pass.cpp index 8213fbb70c14..154180def468 100644 --- a/libcxx/test/containers/associative/multiset/empty.pass.cpp +++ b/libcxx/test/containers/associative/multiset/empty.pass.cpp @@ -16,8 +16,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef std::multiset M; M m; assert(m.empty()); @@ -25,4 +28,16 @@ int main() assert(!m.empty()); m.clear(); assert(m.empty()); + } +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> M; + M m; + assert(m.empty()); + m.insert(M::value_type(1)); + assert(!m.empty()); + m.clear(); + assert(m.empty()); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/equal_range.pass.cpp b/libcxx/test/containers/associative/multiset/equal_range.pass.cpp index 4d8cd98b9dd7..fee94bc97cd6 100644 --- a/libcxx/test/containers/associative/multiset/equal_range.pass.cpp +++ b/libcxx/test/containers/associative/multiset/equal_range.pass.cpp @@ -17,8 +17,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int V; typedef std::multiset M; { @@ -95,4 +98,85 @@ int main() assert(r.first == next(m.begin(), 9)); assert(r.second == next(m.begin(), 9)); } + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::multiset, min_allocator> M; + { + typedef std::pair R; + V ar[] = + { + 5, + 5, + 5, + 7, + 7, + 7, + 9, + 9, + 9 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.equal_range(4); + assert(r.first == next(m.begin(), 0)); + assert(r.second == next(m.begin(), 0)); + r = m.equal_range(5); + assert(r.first == next(m.begin(), 0)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(6); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(7); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(8); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(9); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 9)); + r = m.equal_range(10); + assert(r.first == next(m.begin(), 9)); + assert(r.second == next(m.begin(), 9)); + } + { + typedef std::pair R; + V ar[] = + { + 5, + 5, + 5, + 7, + 7, + 7, + 9, + 9, + 9 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.equal_range(4); + assert(r.first == next(m.begin(), 0)); + assert(r.second == next(m.begin(), 0)); + r = m.equal_range(5); + assert(r.first == next(m.begin(), 0)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(6); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(7); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(8); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(9); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 9)); + r = m.equal_range(10); + assert(r.first == next(m.begin(), 9)); + assert(r.second == next(m.begin(), 9)); + } + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/erase_iter.pass.cpp b/libcxx/test/containers/associative/multiset/erase_iter.pass.cpp index 207a720bdc23..3657f521cb1e 100644 --- a/libcxx/test/containers/associative/multiset/erase_iter.pass.cpp +++ b/libcxx/test/containers/associative/multiset/erase_iter.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -96,4 +98,84 @@ int main() assert(i == m.begin()); assert(i == m.end()); } +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> M; + typedef int V; + typedef M::iterator I; + V ar[] = + { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + I i = m.erase(next(m.cbegin(), 3)); + assert(m.size() == 7); + assert(i == next(m.begin(), 3)); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 5); + assert(*next(m.begin(), 4) == 6); + assert(*next(m.begin(), 5) == 7); + assert(*next(m.begin(), 6) == 8); + + i = m.erase(next(m.cbegin(), 0)); + assert(m.size() == 6); + assert(i == m.begin()); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 3); + assert(*next(m.begin(), 2) == 5); + assert(*next(m.begin(), 3) == 6); + assert(*next(m.begin(), 4) == 7); + assert(*next(m.begin(), 5) == 8); + + i = m.erase(next(m.cbegin(), 5)); + assert(m.size() == 5); + assert(i == m.end()); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 3); + assert(*next(m.begin(), 2) == 5); + assert(*next(m.begin(), 3) == 6); + assert(*next(m.begin(), 4) == 7); + + i = m.erase(next(m.cbegin(), 1)); + assert(m.size() == 4); + assert(i == next(m.begin())); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + assert(*next(m.begin(), 2) == 6); + assert(*next(m.begin(), 3) == 7); + + i = m.erase(next(m.cbegin(), 2)); + assert(m.size() == 3); + assert(i == next(m.begin(), 2)); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + assert(*next(m.begin(), 2) == 7); + + i = m.erase(next(m.cbegin(), 2)); + assert(m.size() == 2); + assert(i == next(m.begin(), 2)); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + + i = m.erase(next(m.cbegin(), 0)); + assert(m.size() == 1); + assert(i == next(m.begin(), 0)); + assert(*next(m.begin(), 0) == 5); + + i = m.erase(m.cbegin()); + assert(m.size() == 0); + assert(i == m.begin()); + assert(i == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/erase_iter_iter.pass.cpp b/libcxx/test/containers/associative/multiset/erase_iter_iter.pass.cpp index 091212815a1f..de4c8783bf39 100644 --- a/libcxx/test/containers/associative/multiset/erase_iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/multiset/erase_iter_iter.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -76,4 +78,64 @@ int main() assert(m.size() == 0); assert(i == m.end()); } +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> M; + typedef int V; + typedef M::iterator I; + V ar[] = + { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5)); + assert(m.size() == 8); + assert(i == next(m.begin(), 5)); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 4); + assert(*next(m.begin(), 4) == 5); + assert(*next(m.begin(), 5) == 6); + assert(*next(m.begin(), 6) == 7); + assert(*next(m.begin(), 7) == 8); + + i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4)); + assert(m.size() == 7); + assert(i == next(m.begin(), 3)); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 5); + assert(*next(m.begin(), 4) == 6); + assert(*next(m.begin(), 5) == 7); + assert(*next(m.begin(), 6) == 8); + + i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5)); + assert(m.size() == 4); + assert(i == next(m.begin(), 2)); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 7); + assert(*next(m.begin(), 3) == 8); + + i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2)); + assert(m.size() == 2); + assert(i == next(m.begin(), 0)); + assert(*next(m.begin(), 0) == 7); + assert(*next(m.begin(), 1) == 8); + + i = m.erase(m.cbegin(), m.cend()); + assert(m.size() == 0); + assert(i == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/erase_key.pass.cpp b/libcxx/test/containers/associative/multiset/erase_key.pass.cpp index 20ba86df10ae..170232904c4d 100644 --- a/libcxx/test/containers/associative/multiset/erase_key.pass.cpp +++ b/libcxx/test/containers/associative/multiset/erase_key.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -70,4 +72,58 @@ int main() assert(m.size() == 0); assert(i == 3); } +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> M; + typedef int V; + typedef M::size_type I; + V ar[] = + { + 3, + 3, + 3, + 5, + 5, + 5, + 7, + 7, + 7 + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 9); + I i = m.erase(6); + assert(m.size() == 9); + assert(i == 0); + assert(*next(m.begin(), 0) == 3); + assert(*next(m.begin(), 1) == 3); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 5); + assert(*next(m.begin(), 4) == 5); + assert(*next(m.begin(), 5) == 5); + assert(*next(m.begin(), 6) == 7); + assert(*next(m.begin(), 7) == 7); + assert(*next(m.begin(), 8) == 7); + + i = m.erase(5); + assert(m.size() == 6); + assert(i == 3); + assert(*next(m.begin(), 0) == 3); + assert(*next(m.begin(), 1) == 3); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 7); + assert(*next(m.begin(), 4) == 7); + assert(*next(m.begin(), 5) == 7); + + i = m.erase(3); + assert(m.size() == 3); + assert(i == 3); + assert(*next(m.begin(), 0) == 7); + assert(*next(m.begin(), 1) == 7); + assert(*next(m.begin(), 2) == 7); + + i = m.erase(7); + assert(m.size() == 0); + assert(i == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/find.pass.cpp b/libcxx/test/containers/associative/multiset/find.pass.cpp index f2af8f617416..53b1844e8efa 100644 --- a/libcxx/test/containers/associative/multiset/find.pass.cpp +++ b/libcxx/test/containers/associative/multiset/find.pass.cpp @@ -17,74 +17,150 @@ #include #include +#include "../../min_allocator.h" + int main() { - typedef int V; - typedef std::multiset M; { - typedef M::iterator R; - V ar[] = + typedef int V; + typedef std::multiset M; { - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12 - }; - M m(ar, ar+sizeof(ar)/sizeof(ar[0])); - R r = m.find(5); - assert(r == m.begin()); - r = m.find(6); - assert(r == next(m.begin())); - r = m.find(7); - assert(r == next(m.begin(), 2)); - r = m.find(8); - assert(r == next(m.begin(), 3)); - r = m.find(9); - assert(r == next(m.begin(), 4)); - r = m.find(10); - assert(r == next(m.begin(), 5)); - r = m.find(11); - assert(r == next(m.begin(), 6)); - r = m.find(12); - assert(r == next(m.begin(), 7)); - r = m.find(4); - assert(r == next(m.begin(), 8)); + typedef M::iterator R; + V ar[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == next(m.begin())); + r = m.find(7); + assert(r == next(m.begin(), 2)); + r = m.find(8); + assert(r == next(m.begin(), 3)); + r = m.find(9); + assert(r == next(m.begin(), 4)); + r = m.find(10); + assert(r == next(m.begin(), 5)); + r = m.find(11); + assert(r == next(m.begin(), 6)); + r = m.find(12); + assert(r == next(m.begin(), 7)); + r = m.find(4); + assert(r == next(m.begin(), 8)); + } + { + typedef M::const_iterator R; + V ar[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == next(m.begin())); + r = m.find(7); + assert(r == next(m.begin(), 2)); + r = m.find(8); + assert(r == next(m.begin(), 3)); + r = m.find(9); + assert(r == next(m.begin(), 4)); + r = m.find(10); + assert(r == next(m.begin(), 5)); + r = m.find(11); + assert(r == next(m.begin(), 6)); + r = m.find(12); + assert(r == next(m.begin(), 7)); + r = m.find(4); + assert(r == next(m.begin(), 8)); + } } +#if __cplusplus >= 201103L { - typedef M::const_iterator R; - V ar[] = + typedef int V; + typedef std::multiset, min_allocator> M; { - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12 - }; - const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); - R r = m.find(5); - assert(r == m.begin()); - r = m.find(6); - assert(r == next(m.begin())); - r = m.find(7); - assert(r == next(m.begin(), 2)); - r = m.find(8); - assert(r == next(m.begin(), 3)); - r = m.find(9); - assert(r == next(m.begin(), 4)); - r = m.find(10); - assert(r == next(m.begin(), 5)); - r = m.find(11); - assert(r == next(m.begin(), 6)); - r = m.find(12); - assert(r == next(m.begin(), 7)); - r = m.find(4); - assert(r == next(m.begin(), 8)); + typedef M::iterator R; + V ar[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == next(m.begin())); + r = m.find(7); + assert(r == next(m.begin(), 2)); + r = m.find(8); + assert(r == next(m.begin(), 3)); + r = m.find(9); + assert(r == next(m.begin(), 4)); + r = m.find(10); + assert(r == next(m.begin(), 5)); + r = m.find(11); + assert(r == next(m.begin(), 6)); + r = m.find(12); + assert(r == next(m.begin(), 7)); + r = m.find(4); + assert(r == next(m.begin(), 8)); + } + { + typedef M::const_iterator R; + V ar[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == next(m.begin())); + r = m.find(7); + assert(r == next(m.begin(), 2)); + r = m.find(8); + assert(r == next(m.begin(), 3)); + r = m.find(9); + assert(r == next(m.begin(), 4)); + r = m.find(10); + assert(r == next(m.begin(), 5)); + r = m.find(11); + assert(r == next(m.begin(), 6)); + r = m.find(12); + assert(r == next(m.begin(), 7)); + r = m.find(4); + assert(r == next(m.begin(), 8)); + } } +#endif } diff --git a/libcxx/test/containers/associative/multiset/insert_cv.pass.cpp b/libcxx/test/containers/associative/multiset/insert_cv.pass.cpp index 2673ae74c158..57e1e98f5003 100644 --- a/libcxx/test/containers/associative/multiset/insert_cv.pass.cpp +++ b/libcxx/test/containers/associative/multiset/insert_cv.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -42,4 +44,30 @@ int main() assert(m.size() == 4); assert(*r == 3); } +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> M; + typedef M::iterator R; + M m; + R r = m.insert(M::value_type(2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(*r == 2); + + r = m.insert(M::value_type(1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(*r == 1); + + r = m.insert(M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(*r == 3); + + r = m.insert(M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 4); + assert(*r == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/insert_initializer_list.pass.cpp b/libcxx/test/containers/associative/multiset/insert_initializer_list.pass.cpp index 4f5691b09bf4..c609d242ae29 100644 --- a/libcxx/test/containers/associative/multiset/insert_initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/multiset/insert_initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include #include +#include "../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::multiset C; typedef C::value_type V; C m = {10, 8}; @@ -34,5 +37,25 @@ int main() assert(*++i == V(6)); assert(*++i == V(8)); assert(*++i == V(10)); + } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> C; + typedef C::value_type V; + C m = {10, 8}; + m.insert({1, 2, 3, 4, 5, 6}); + assert(m.size() == 8); + assert(distance(m.begin(), m.end()) == m.size()); + C::const_iterator i = m.cbegin(); + assert(*i == V(1)); + assert(*++i == V(2)); + assert(*++i == V(3)); + assert(*++i == V(4)); + assert(*++i == V(5)); + assert(*++i == V(6)); + assert(*++i == V(8)); + assert(*++i == V(10)); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/insert_iter_cv.pass.cpp b/libcxx/test/containers/associative/multiset/insert_iter_cv.pass.cpp index 6e4986292d17..fccc2b71960e 100644 --- a/libcxx/test/containers/associative/multiset/insert_iter_cv.pass.cpp +++ b/libcxx/test/containers/associative/multiset/insert_iter_cv.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -42,4 +44,30 @@ int main() assert(m.size() == 4); assert(*r == 3); } +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> M; + typedef M::iterator R; + M m; + R r = m.insert(m.cend(), M::value_type(2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(*r == 2); + + r = m.insert(m.cend(), M::value_type(1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(*r == 1); + + r = m.insert(m.cend(), M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(*r == 3); + + r = m.insert(m.cend(), M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 4); + assert(*r == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/insert_iter_iter.pass.cpp b/libcxx/test/containers/associative/multiset/insert_iter_iter.pass.cpp index 231e0c57a6e1..3cfa9dd16c49 100644 --- a/libcxx/test/containers/associative/multiset/insert_iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/multiset/insert_iter_iter.pass.cpp @@ -18,6 +18,7 @@ #include #include "test_iterators.h" +#include "../../min_allocator.h" int main() { @@ -50,4 +51,35 @@ int main() assert(*next(m.begin(), 7) == 3); assert(*next(m.begin(), 8) == 3); } +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> M; + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + M m; + m.insert(input_iterator(ar), + input_iterator(ar + sizeof(ar)/sizeof(ar[0]))); + assert(m.size() == 9); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 1); + assert(*next(m.begin(), 2) == 1); + assert(*next(m.begin(), 3) == 2); + assert(*next(m.begin(), 4) == 2); + assert(*next(m.begin(), 5) == 2); + assert(*next(m.begin(), 6) == 3); + assert(*next(m.begin(), 7) == 3); + assert(*next(m.begin(), 8) == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/insert_iter_rv.pass.cpp b/libcxx/test/containers/associative/multiset/insert_iter_rv.pass.cpp index 3700dd18888a..f09d97de8277 100644 --- a/libcxx/test/containers/associative/multiset/insert_iter_rv.pass.cpp +++ b/libcxx/test/containers/associative/multiset/insert_iter_rv.pass.cpp @@ -17,6 +17,7 @@ #include #include "../../MoveOnly.h" +#include "../../min_allocator.h" int main() { @@ -46,4 +47,30 @@ int main() assert(*r == 3); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> M; + typedef M::iterator R; + M m; + R r = m.insert(m.cend(), M::value_type(2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(*r == 2); + + r = m.insert(m.cend(), M::value_type(1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(*r == 1); + + r = m.insert(m.cend(), M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(*r == 3); + + r = m.insert(m.cend(), M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 4); + assert(*r == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/insert_rv.pass.cpp b/libcxx/test/containers/associative/multiset/insert_rv.pass.cpp index a65b67a9533d..e9e773ccd733 100644 --- a/libcxx/test/containers/associative/multiset/insert_rv.pass.cpp +++ b/libcxx/test/containers/associative/multiset/insert_rv.pass.cpp @@ -17,6 +17,7 @@ #include #include "../../MoveOnly.h" +#include "../../min_allocator.h" int main() { @@ -46,4 +47,30 @@ int main() assert(*r == 3); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> M; + typedef M::iterator R; + M m; + R r = m.insert(M::value_type(2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(*r == 2); + + r = m.insert(M::value_type(1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(*r == 1); + + r = m.insert(M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(*r == 3); + + r = m.insert(M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 4); + assert(*r == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/iterator.pass.cpp b/libcxx/test/containers/associative/multiset/iterator.pass.cpp index 1b202191b3d1..2a7b209e9c0d 100644 --- a/libcxx/test/containers/associative/multiset/iterator.pass.cpp +++ b/libcxx/test/containers/associative/multiset/iterator.pass.cpp @@ -29,6 +29,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -105,10 +107,92 @@ int main() assert(std::distance(m.cbegin(), m.cend()) == m.size()); assert(std::distance(m.rbegin(), m.rend()) == m.size()); assert(std::distance(m.crbegin(), m.crend()) == m.size()); - std::multiset::const_iterator i; + std::multiset::const_iterator i; i = m.begin(); for (int j = 1; j <= 8; ++j) for (int k = 0; k < 3; ++k, ++i) assert(*i == j); } +#if __cplusplus >= 201103L + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3, + 4, + 4, + 4, + 5, + 5, + 5, + 6, + 6, + 6, + 7, + 7, + 7, + 8, + 8, + 8 + }; + std::multiset, min_allocator> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(std::distance(m.begin(), m.end()) == m.size()); + assert(std::distance(m.rbegin(), m.rend()) == m.size()); + std::multiset, min_allocator>::iterator i; + i = m.begin(); + std::multiset, min_allocator>::const_iterator k = i; + assert(i == k); + for (int j = 1; j <= 8; ++j) + for (int k = 0; k < 3; ++k, ++i) + assert(*i == j); + } + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3, + 4, + 4, + 4, + 5, + 5, + 5, + 6, + 6, + 6, + 7, + 7, + 7, + 8, + 8, + 8 + }; + const std::multiset, min_allocator> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(std::distance(m.begin(), m.end()) == m.size()); + assert(std::distance(m.cbegin(), m.cend()) == m.size()); + assert(std::distance(m.rbegin(), m.rend()) == m.size()); + assert(std::distance(m.crbegin(), m.crend()) == m.size()); + std::multiset, min_allocator>::const_iterator i; + i = m.begin(); + for (int j = 1; j <= 8; ++j) + for (int k = 0; k < 3; ++k, ++i) + assert(*i == j); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/lower_bound.pass.cpp b/libcxx/test/containers/associative/multiset/lower_bound.pass.cpp index 585c341cd238..537ccd3aff13 100644 --- a/libcxx/test/containers/associative/multiset/lower_bound.pass.cpp +++ b/libcxx/test/containers/associative/multiset/lower_bound.pass.cpp @@ -17,68 +17,138 @@ #include #include +#include "../../min_allocator.h" + int main() { - typedef int V; - typedef std::multiset M; { - typedef M::iterator R; - V ar[] = + typedef int V; + typedef std::multiset M; { - 5, - 5, - 5, - 7, - 7, - 7, - 9, - 9, - 9 - }; - M m(ar, ar+sizeof(ar)/sizeof(ar[0])); - R r = m.lower_bound(4); - assert(r == next(m.begin(), 0)); - r = m.lower_bound(5); - assert(r == next(m.begin(), 0)); - r = m.lower_bound(6); - assert(r == next(m.begin(), 3)); - r = m.lower_bound(7); - assert(r == next(m.begin(), 3)); - r = m.lower_bound(8); - assert(r == next(m.begin(), 6)); - r = m.lower_bound(9); - assert(r == next(m.begin(), 6)); - r = m.lower_bound(11); - assert(r == next(m.begin(), 9)); + typedef M::iterator R; + V ar[] = + { + 5, + 5, + 5, + 7, + 7, + 7, + 9, + 9, + 9 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(4); + assert(r == next(m.begin(), 0)); + r = m.lower_bound(5); + assert(r == next(m.begin(), 0)); + r = m.lower_bound(6); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(7); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(9); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(11); + assert(r == next(m.begin(), 9)); + } + { + typedef M::const_iterator R; + V ar[] = + { + 5, + 5, + 5, + 7, + 7, + 7, + 9, + 9, + 9 + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(4); + assert(r == next(m.begin(), 0)); + r = m.lower_bound(5); + assert(r == next(m.begin(), 0)); + r = m.lower_bound(6); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(7); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(9); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(11); + assert(r == next(m.begin(), 9)); + } } +#if __cplusplus >= 201103L { - typedef M::const_iterator R; - V ar[] = + typedef int V; + typedef std::multiset, min_allocator> M; { - 5, - 5, - 5, - 7, - 7, - 7, - 9, - 9, - 9 - }; - const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); - R r = m.lower_bound(4); - assert(r == next(m.begin(), 0)); - r = m.lower_bound(5); - assert(r == next(m.begin(), 0)); - r = m.lower_bound(6); - assert(r == next(m.begin(), 3)); - r = m.lower_bound(7); - assert(r == next(m.begin(), 3)); - r = m.lower_bound(8); - assert(r == next(m.begin(), 6)); - r = m.lower_bound(9); - assert(r == next(m.begin(), 6)); - r = m.lower_bound(11); - assert(r == next(m.begin(), 9)); + typedef M::iterator R; + V ar[] = + { + 5, + 5, + 5, + 7, + 7, + 7, + 9, + 9, + 9 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(4); + assert(r == next(m.begin(), 0)); + r = m.lower_bound(5); + assert(r == next(m.begin(), 0)); + r = m.lower_bound(6); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(7); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(9); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(11); + assert(r == next(m.begin(), 9)); + } + { + typedef M::const_iterator R; + V ar[] = + { + 5, + 5, + 5, + 7, + 7, + 7, + 9, + 9, + 9 + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(4); + assert(r == next(m.begin(), 0)); + r = m.lower_bound(5); + assert(r == next(m.begin(), 0)); + r = m.lower_bound(6); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(7); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(9); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(11); + assert(r == next(m.begin(), 9)); + } } +#endif } diff --git a/libcxx/test/containers/associative/multiset/max_size.pass.cpp b/libcxx/test/containers/associative/multiset/max_size.pass.cpp index cf3581ef5dcf..a209d700ee60 100644 --- a/libcxx/test/containers/associative/multiset/max_size.pass.cpp +++ b/libcxx/test/containers/associative/multiset/max_size.pass.cpp @@ -16,9 +16,20 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef std::multiset M; M m; assert(m.max_size() != 0); + } +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> M; + M m; + assert(m.max_size() != 0); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp b/libcxx/test/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp index a6834afe0db1..16ba28abfca9 100644 --- a/libcxx/test/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::multiset C; typedef C::value_type V; C m = {10, 8}; @@ -32,5 +35,23 @@ int main() assert(*++i == V(4)); assert(*++i == V(5)); assert(*++i == V(6)); + } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> C; + typedef C::value_type V; + C m = {10, 8}; + m = {1, 2, 3, 4, 5, 6}; + assert(m.size() == 6); + assert(distance(m.begin(), m.end()) == 6); + C::const_iterator i = m.cbegin(); + assert(*i == V(1)); + assert(*++i == V(2)); + assert(*++i == V(3)); + assert(*++i == V(4)); + assert(*++i == V(5)); + assert(*++i == V(6)); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/multiset.cons/default.pass.cpp b/libcxx/test/containers/associative/multiset/multiset.cons/default.pass.cpp index 72fd822f7450..cf24bf771ce6 100644 --- a/libcxx/test/containers/associative/multiset/multiset.cons/default.pass.cpp +++ b/libcxx/test/containers/associative/multiset/multiset.cons/default.pass.cpp @@ -16,9 +16,20 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { std::multiset m; assert(m.empty()); assert(m.begin() == m.end()); + } +#if __cplusplus >= 201103L + { + std::multiset, min_allocator> m; + assert(m.empty()); + assert(m.begin() == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp b/libcxx/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp index 4ee2b4daa545..9e3186d92334 100644 --- a/libcxx/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::multiset C; typedef C::value_type V; C m = {1, 2, 3, 4, 5, 6}; @@ -31,5 +34,22 @@ int main() assert(*++i == V(4)); assert(*++i == V(5)); assert(*++i == V(6)); + } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> C; + typedef C::value_type V; + C m = {1, 2, 3, 4, 5, 6}; + assert(m.size() == 6); + assert(distance(m.begin(), m.end()) == 6); + C::const_iterator i = m.cbegin(); + assert(*i == V(1)); + assert(*++i == V(2)); + assert(*++i == V(3)); + assert(*++i == V(4)); + assert(*++i == V(5)); + assert(*++i == V(6)); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp b/libcxx/test/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp index d8a3c1453708..3f0053996f3e 100644 --- a/libcxx/test/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp @@ -18,9 +18,11 @@ #include #include "test_iterators.h" +#include "../../../min_allocator.h" int main() { + { typedef int V; V ar[] = { @@ -47,4 +49,35 @@ int main() assert(*next(m.begin(), 6) == 3); assert(*next(m.begin(), 7) == 3); assert(*next(m.begin(), 8) == 3); + } +#if __cplusplus >= 201103L + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + std::multiset, min_allocator> m(input_iterator(ar), + input_iterator(ar+sizeof(ar)/sizeof(ar[0]))); + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 1); + assert(*next(m.begin(), 2) == 1); + assert(*next(m.begin(), 3) == 2); + assert(*next(m.begin(), 4) == 2); + assert(*next(m.begin(), 5) == 2); + assert(*next(m.begin(), 6) == 3); + assert(*next(m.begin(), 7) == 3); + assert(*next(m.begin(), 8) == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/multiset.cons/move.pass.cpp b/libcxx/test/containers/associative/multiset/multiset.cons/move.pass.cpp index dee53d98df6c..97f593bb32b6 100644 --- a/libcxx/test/containers/associative/multiset/multiset.cons/move.pass.cpp +++ b/libcxx/test/containers/associative/multiset/multiset.cons/move.pass.cpp @@ -18,6 +18,7 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -76,4 +77,43 @@ int main() assert(distance(mo.begin(), mo.end()) == 0); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + typedef test_compare > C; + typedef min_allocator A; + std::multiset mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::multiset m = std::move(mo); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 1); + assert(*next(m.begin(), 2) == 1); + assert(*next(m.begin(), 3) == 2); + assert(*next(m.begin(), 4) == 2); + assert(*next(m.begin(), 5) == 2); + assert(*next(m.begin(), 6) == 3); + assert(*next(m.begin(), 7) == 3); + assert(*next(m.begin(), 8) == 3); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 0); + assert(distance(mo.begin(), mo.end()) == 0); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/multiset.cons/move_assign.pass.cpp b/libcxx/test/containers/associative/multiset/multiset.cons/move_assign.pass.cpp index f17d29bb4939..e02942ffeeab 100644 --- a/libcxx/test/containers/associative/multiset/multiset.cons/move_assign.pass.cpp +++ b/libcxx/test/containers/associative/multiset/multiset.cons/move_assign.pass.cpp @@ -19,6 +19,7 @@ #include "../../../MoveOnly.h" #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -141,4 +142,45 @@ int main() assert(m1.empty()); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef MoveOnly V; + typedef test_compare > C; + typedef min_allocator A; + typedef std::multiset M; + typedef std::move_iterator I; + V a1[] = + { + V(1), + V(1), + V(1), + V(2), + V(2), + V(2), + V(3), + V(3), + V(3) + }; + M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A()); + V a2[] = + { + V(1), + V(1), + V(1), + V(2), + V(2), + V(2), + V(3), + V(3), + V(3) + }; + M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A()); + M m3(C(3), A()); + m3 = std::move(m1); + assert(m3 == m2); + assert(m3.get_allocator() == A()); + assert(m3.key_comp() == C(5)); + assert(m1.empty()); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/multiset.special/member_swap.pass.cpp b/libcxx/test/containers/associative/multiset/multiset.special/member_swap.pass.cpp index db6ab15a5bcd..8d5b1e822bc3 100644 --- a/libcxx/test/containers/associative/multiset/multiset.special/member_swap.pass.cpp +++ b/libcxx/test/containers/associative/multiset/multiset.special/member_swap.pass.cpp @@ -16,8 +16,11 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { typedef int V; typedef std::multiset M; { @@ -104,4 +107,95 @@ int main() assert(m1 == m2_save); assert(m2 == m1_save); } + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::multiset, min_allocator> M; + { + V ar1[] = + { + }; + V ar2[] = + { + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + }; + V ar2[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + 1, + 2, + 3, + 4 + }; + V ar2[] = + { + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + 1, + 2, + 3, + 4 + }; + V ar2[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/size.pass.cpp b/libcxx/test/containers/associative/multiset/size.pass.cpp index f7b12388ce89..8129a9c3675b 100644 --- a/libcxx/test/containers/associative/multiset/size.pass.cpp +++ b/libcxx/test/containers/associative/multiset/size.pass.cpp @@ -16,8 +16,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef std::multiset M; M m; assert(m.size() == 0); @@ -33,4 +36,24 @@ int main() assert(m.size() == 1); m.erase(m.begin()); assert(m.size() == 0); + } +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> M; + M m; + assert(m.size() == 0); + m.insert(M::value_type(2)); + assert(m.size() == 1); + m.insert(M::value_type(1)); + assert(m.size() == 2); + m.insert(M::value_type(2)); + assert(m.size() == 3); + m.erase(m.begin()); + assert(m.size() == 2); + m.erase(m.begin()); + assert(m.size() == 1); + m.erase(m.begin()); + assert(m.size() == 0); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/types.pass.cpp b/libcxx/test/containers/associative/multiset/types.pass.cpp index de5ee694fa41..e3331cddc6db 100644 --- a/libcxx/test/containers/associative/multiset/types.pass.cpp +++ b/libcxx/test/containers/associative/multiset/types.pass.cpp @@ -32,8 +32,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { static_assert((std::is_same::key_type, int>::value), ""); static_assert((std::is_same::value_type, int>::value), ""); static_assert((std::is_same::key_compare, std::less >::value), ""); @@ -45,4 +48,20 @@ int main() static_assert((std::is_same::const_pointer, const int*>::value), ""); static_assert((std::is_same::size_type, std::size_t>::value), ""); static_assert((std::is_same::difference_type, std::ptrdiff_t>::value), ""); + } +#if __cplusplus >= 201103L + { + static_assert((std::is_same, min_allocator>::key_type, int>::value), ""); + static_assert((std::is_same, min_allocator>::value_type, int>::value), ""); + static_assert((std::is_same, min_allocator>::key_compare, std::less >::value), ""); + static_assert((std::is_same, min_allocator>::value_compare, std::less >::value), ""); + static_assert((std::is_same, min_allocator>::allocator_type, min_allocator>::value), ""); + static_assert((std::is_same, min_allocator>::reference, int&>::value), ""); + static_assert((std::is_same, min_allocator>::const_reference, const int&>::value), ""); + static_assert((std::is_same, min_allocator>::pointer, min_pointer>::value), ""); + static_assert((std::is_same, min_allocator>::const_pointer, min_pointer>::value), ""); + static_assert((std::is_same, min_allocator>::size_type, std::size_t>::value), ""); + static_assert((std::is_same, min_allocator>::difference_type, std::ptrdiff_t>::value), ""); + } +#endif } diff --git a/libcxx/test/containers/associative/multiset/upper_bound.pass.cpp b/libcxx/test/containers/associative/multiset/upper_bound.pass.cpp index 592a3fcd82bc..332254eef684 100644 --- a/libcxx/test/containers/associative/multiset/upper_bound.pass.cpp +++ b/libcxx/test/containers/associative/multiset/upper_bound.pass.cpp @@ -17,8 +17,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int V; typedef std::multiset M; { @@ -81,4 +84,71 @@ int main() r = m.upper_bound(11); assert(r == next(m.begin(), 9)); } + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::multiset, min_allocator> M; + { + typedef M::iterator R; + V ar[] = + { + 5, + 5, + 5, + 7, + 7, + 7, + 9, + 9, + 9 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(4); + assert(r == next(m.begin(), 0)); + r = m.upper_bound(5); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 9)); + r = m.upper_bound(11); + assert(r == next(m.begin(), 9)); + } + { + typedef M::const_iterator R; + V ar[] = + { + 5, + 5, + 5, + 7, + 7, + 7, + 9, + 9, + 9 + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(4); + assert(r == next(m.begin(), 0)); + r = m.upper_bound(5); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 9)); + r = m.upper_bound(11); + assert(r == next(m.begin(), 9)); + } + } +#endif } diff --git a/libcxx/test/containers/associative/set/clear.pass.cpp b/libcxx/test/containers/associative/set/clear.pass.cpp index aa632c7f1d9d..c6e01023f650 100644 --- a/libcxx/test/containers/associative/set/clear.pass.cpp +++ b/libcxx/test/containers/associative/set/clear.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -37,4 +39,25 @@ int main() m.clear(); assert(m.size() == 0); } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> M; + typedef int V; + V ar[] = + { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + m.clear(); + assert(m.size() == 0); + } +#endif } diff --git a/libcxx/test/containers/associative/set/count.pass.cpp b/libcxx/test/containers/associative/set/count.pass.cpp index 4a678a198a70..7d7a31ad0dbb 100644 --- a/libcxx/test/containers/associative/set/count.pass.cpp +++ b/libcxx/test/containers/associative/set/count.pass.cpp @@ -16,11 +16,13 @@ #include #include +#include "../../min_allocator.h" + int main() { - typedef int V; - typedef std::set M; { + typedef int V; + typedef std::set M; typedef M::size_type R; V ar[] = { @@ -53,4 +55,41 @@ int main() r = m.count(4); assert(r == 0); } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::set, min_allocator> M; + typedef M::size_type R; + V ar[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.count(5); + assert(r == 1); + r = m.count(6); + assert(r == 1); + r = m.count(7); + assert(r == 1); + r = m.count(8); + assert(r == 1); + r = m.count(9); + assert(r == 1); + r = m.count(10); + assert(r == 1); + r = m.count(11); + assert(r == 1); + r = m.count(12); + assert(r == 1); + r = m.count(4); + assert(r == 0); + } +#endif } diff --git a/libcxx/test/containers/associative/set/emplace.pass.cpp b/libcxx/test/containers/associative/set/emplace.pass.cpp index e322ff1df6ae..69fdbeeb6b2d 100644 --- a/libcxx/test/containers/associative/set/emplace.pass.cpp +++ b/libcxx/test/containers/associative/set/emplace.pass.cpp @@ -19,6 +19,7 @@ #include "../../Emplaceable.h" #include "../../DefaultOnly.h" +#include "../../min_allocator.h" int main() { @@ -73,5 +74,17 @@ int main() assert(m.size() == 1); assert(*r.first == 2); } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> M; + typedef std::pair R; + M m; + R r = m.emplace(M::value_type(2)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(*r.first == 2); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/set/emplace_hint.pass.cpp b/libcxx/test/containers/associative/set/emplace_hint.pass.cpp index be5d73dac93b..8e7fbbc40330 100644 --- a/libcxx/test/containers/associative/set/emplace_hint.pass.cpp +++ b/libcxx/test/containers/associative/set/emplace_hint.pass.cpp @@ -19,6 +19,7 @@ #include "../../Emplaceable.h" #include "../../DefaultOnly.h" +#include "../../min_allocator.h" int main() { @@ -67,5 +68,16 @@ int main() assert(m.size() == 1); assert(*r == 2); } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> M; + typedef M::iterator R; + M m; + R r = m.emplace_hint(m.cend(), M::value_type(2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(*r == 2); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/set/empty.pass.cpp b/libcxx/test/containers/associative/set/empty.pass.cpp index 615bc61dd446..305ae39ff900 100644 --- a/libcxx/test/containers/associative/set/empty.pass.cpp +++ b/libcxx/test/containers/associative/set/empty.pass.cpp @@ -16,8 +16,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef std::set M; M m; assert(m.empty()); @@ -25,4 +28,16 @@ int main() assert(!m.empty()); m.clear(); assert(m.empty()); + } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> M; + M m; + assert(m.empty()); + m.insert(M::value_type(1)); + assert(!m.empty()); + m.clear(); + assert(m.empty()); + } +#endif } diff --git a/libcxx/test/containers/associative/set/equal_range.pass.cpp b/libcxx/test/containers/associative/set/equal_range.pass.cpp index 7b17a4713719..95a933ef4364 100644 --- a/libcxx/test/containers/associative/set/equal_range.pass.cpp +++ b/libcxx/test/containers/associative/set/equal_range.pass.cpp @@ -17,8 +17,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int V; typedef std::set M; { @@ -153,4 +156,75 @@ int main() assert(r.first == next(m.begin(), 8)); assert(r.second == next(m.begin(), 8)); } + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::set, min_allocator> M; + typedef std::pair R; + V ar[] = + { + 5, + 7, + 9, + 11, + 13, + 15, + 17, + 19 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.equal_range(5); + assert(r.first == next(m.begin(), 0)); + assert(r.second == next(m.begin(), 1)); + r = m.equal_range(7); + assert(r.first == next(m.begin(), 1)); + assert(r.second == next(m.begin(), 2)); + r = m.equal_range(9); + assert(r.first == next(m.begin(), 2)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(11); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 4)); + r = m.equal_range(13); + assert(r.first == next(m.begin(), 4)); + assert(r.second == next(m.begin(), 5)); + r = m.equal_range(15); + assert(r.first == next(m.begin(), 5)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(17); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 7)); + r = m.equal_range(19); + assert(r.first == next(m.begin(), 7)); + assert(r.second == next(m.begin(), 8)); + r = m.equal_range(4); + assert(r.first == next(m.begin(), 0)); + assert(r.second == next(m.begin(), 0)); + r = m.equal_range(6); + assert(r.first == next(m.begin(), 1)); + assert(r.second == next(m.begin(), 1)); + r = m.equal_range(8); + assert(r.first == next(m.begin(), 2)); + assert(r.second == next(m.begin(), 2)); + r = m.equal_range(10); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(12); + assert(r.first == next(m.begin(), 4)); + assert(r.second == next(m.begin(), 4)); + r = m.equal_range(14); + assert(r.first == next(m.begin(), 5)); + assert(r.second == next(m.begin(), 5)); + r = m.equal_range(16); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(18); + assert(r.first == next(m.begin(), 7)); + assert(r.second == next(m.begin(), 7)); + r = m.equal_range(20); + assert(r.first == next(m.begin(), 8)); + assert(r.second == next(m.begin(), 8)); + } +#endif } diff --git a/libcxx/test/containers/associative/set/erase_iter.pass.cpp b/libcxx/test/containers/associative/set/erase_iter.pass.cpp index 949e973961dd..f05d4819e075 100644 --- a/libcxx/test/containers/associative/set/erase_iter.pass.cpp +++ b/libcxx/test/containers/associative/set/erase_iter.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -96,4 +98,84 @@ int main() assert(i == m.begin()); assert(i == m.end()); } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> M; + typedef int V; + typedef M::iterator I; + V ar[] = + { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + I i = m.erase(next(m.cbegin(), 3)); + assert(m.size() == 7); + assert(i == next(m.begin(), 3)); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 5); + assert(*next(m.begin(), 4) == 6); + assert(*next(m.begin(), 5) == 7); + assert(*next(m.begin(), 6) == 8); + + i = m.erase(next(m.cbegin(), 0)); + assert(m.size() == 6); + assert(i == m.begin()); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 3); + assert(*next(m.begin(), 2) == 5); + assert(*next(m.begin(), 3) == 6); + assert(*next(m.begin(), 4) == 7); + assert(*next(m.begin(), 5) == 8); + + i = m.erase(next(m.cbegin(), 5)); + assert(m.size() == 5); + assert(i == m.end()); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 3); + assert(*next(m.begin(), 2) == 5); + assert(*next(m.begin(), 3) == 6); + assert(*next(m.begin(), 4) == 7); + + i = m.erase(next(m.cbegin(), 1)); + assert(m.size() == 4); + assert(i == next(m.begin())); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + assert(*next(m.begin(), 2) == 6); + assert(*next(m.begin(), 3) == 7); + + i = m.erase(next(m.cbegin(), 2)); + assert(m.size() == 3); + assert(i == next(m.begin(), 2)); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + assert(*next(m.begin(), 2) == 7); + + i = m.erase(next(m.cbegin(), 2)); + assert(m.size() == 2); + assert(i == next(m.begin(), 2)); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + + i = m.erase(next(m.cbegin(), 0)); + assert(m.size() == 1); + assert(i == next(m.begin(), 0)); + assert(*next(m.begin(), 0) == 5); + + i = m.erase(m.cbegin()); + assert(m.size() == 0); + assert(i == m.begin()); + assert(i == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/set/erase_iter_iter.pass.cpp b/libcxx/test/containers/associative/set/erase_iter_iter.pass.cpp index 283b8b57a2f4..953d1be8bd49 100644 --- a/libcxx/test/containers/associative/set/erase_iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/set/erase_iter_iter.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -76,4 +78,64 @@ int main() assert(m.size() == 0); assert(i == m.end()); } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> M; + typedef int V; + typedef M::iterator I; + V ar[] = + { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5)); + assert(m.size() == 8); + assert(i == next(m.begin(), 5)); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 4); + assert(*next(m.begin(), 4) == 5); + assert(*next(m.begin(), 5) == 6); + assert(*next(m.begin(), 6) == 7); + assert(*next(m.begin(), 7) == 8); + + i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4)); + assert(m.size() == 7); + assert(i == next(m.begin(), 3)); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 5); + assert(*next(m.begin(), 4) == 6); + assert(*next(m.begin(), 5) == 7); + assert(*next(m.begin(), 6) == 8); + + i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5)); + assert(m.size() == 4); + assert(i == next(m.begin(), 2)); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 7); + assert(*next(m.begin(), 3) == 8); + + i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2)); + assert(m.size() == 2); + assert(i == next(m.begin(), 0)); + assert(*next(m.begin(), 0) == 7); + assert(*next(m.begin(), 1) == 8); + + i = m.erase(m.cbegin(), m.cend()); + assert(m.size() == 0); + assert(i == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/set/erase_key.pass.cpp b/libcxx/test/containers/associative/set/erase_key.pass.cpp index 61455b6c94c3..12ee0af980ed 100644 --- a/libcxx/test/containers/associative/set/erase_key.pass.cpp +++ b/libcxx/test/containers/associative/set/erase_key.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -107,4 +109,95 @@ int main() assert(m.size() == 0); assert(i == 1); } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> M; + typedef int V; + typedef M::size_type I; + V ar[] = + { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + I i = m.erase(9); + assert(m.size() == 8); + assert(i == 0); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 4); + assert(*next(m.begin(), 4) == 5); + assert(*next(m.begin(), 5) == 6); + assert(*next(m.begin(), 6) == 7); + assert(*next(m.begin(), 7) == 8); + + i = m.erase(4); + assert(m.size() == 7); + assert(i == 1); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 5); + assert(*next(m.begin(), 4) == 6); + assert(*next(m.begin(), 5) == 7); + assert(*next(m.begin(), 6) == 8); + + i = m.erase(1); + assert(m.size() == 6); + assert(i == 1); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 3); + assert(*next(m.begin(), 2) == 5); + assert(*next(m.begin(), 3) == 6); + assert(*next(m.begin(), 4) == 7); + assert(*next(m.begin(), 5) == 8); + + i = m.erase(8); + assert(m.size() == 5); + assert(i == 1); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 3); + assert(*next(m.begin(), 2) == 5); + assert(*next(m.begin(), 3) == 6); + assert(*next(m.begin(), 4) == 7); + + i = m.erase(3); + assert(m.size() == 4); + assert(i == 1); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + assert(*next(m.begin(), 2) == 6); + assert(*next(m.begin(), 3) == 7); + + i = m.erase(6); + assert(m.size() == 3); + assert(i == 1); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + assert(*next(m.begin(), 2) == 7); + + i = m.erase(7); + assert(m.size() == 2); + assert(i == 1); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + + i = m.erase(2); + assert(m.size() == 1); + assert(i == 1); + assert(*next(m.begin(), 0) == 5); + + i = m.erase(5); + assert(m.size() == 0); + assert(i == 1); + } +#endif } diff --git a/libcxx/test/containers/associative/set/find.pass.cpp b/libcxx/test/containers/associative/set/find.pass.cpp index 96ab73b37b52..b661898a8619 100644 --- a/libcxx/test/containers/associative/set/find.pass.cpp +++ b/libcxx/test/containers/associative/set/find.pass.cpp @@ -17,8 +17,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int V; typedef std::set M; { @@ -87,4 +90,77 @@ int main() r = m.find(4); assert(r == next(m.begin(), 8)); } + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::set, min_allocator> M; + { + typedef M::iterator R; + V ar[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == next(m.begin())); + r = m.find(7); + assert(r == next(m.begin(), 2)); + r = m.find(8); + assert(r == next(m.begin(), 3)); + r = m.find(9); + assert(r == next(m.begin(), 4)); + r = m.find(10); + assert(r == next(m.begin(), 5)); + r = m.find(11); + assert(r == next(m.begin(), 6)); + r = m.find(12); + assert(r == next(m.begin(), 7)); + r = m.find(4); + assert(r == next(m.begin(), 8)); + } + { + typedef M::const_iterator R; + V ar[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == next(m.begin())); + r = m.find(7); + assert(r == next(m.begin(), 2)); + r = m.find(8); + assert(r == next(m.begin(), 3)); + r = m.find(9); + assert(r == next(m.begin(), 4)); + r = m.find(10); + assert(r == next(m.begin(), 5)); + r = m.find(11); + assert(r == next(m.begin(), 6)); + r = m.find(12); + assert(r == next(m.begin(), 7)); + r = m.find(4); + assert(r == next(m.begin(), 8)); + } + } +#endif } diff --git a/libcxx/test/containers/associative/set/insert_cv.pass.cpp b/libcxx/test/containers/associative/set/insert_cv.pass.cpp index 9cbb61618c14..eabd1a8722ae 100644 --- a/libcxx/test/containers/associative/set/insert_cv.pass.cpp +++ b/libcxx/test/containers/associative/set/insert_cv.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -46,4 +48,34 @@ int main() assert(m.size() == 3); assert(*r.first == 3); } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> M; + typedef std::pair R; + M m; + R r = m.insert(M::value_type(2)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(*r.first == 2); + + r = m.insert(M::value_type(1)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 2); + assert(*r.first == 1); + + r = m.insert(M::value_type(3)); + assert(r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(*r.first == 3); + + r = m.insert(M::value_type(3)); + assert(!r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(*r.first == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/set/insert_initializer_list.pass.cpp b/libcxx/test/containers/associative/set/insert_initializer_list.pass.cpp index e9245cd46b2a..d75e8a8bcbda 100644 --- a/libcxx/test/containers/associative/set/insert_initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/set/insert_initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include #include +#include "../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::set C; typedef C::value_type V; C m = {10, 8}; @@ -34,5 +37,25 @@ int main() assert(*++i == V(6)); assert(*++i == V(8)); assert(*++i == V(10)); + } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> C; + typedef C::value_type V; + C m = {10, 8}; + m.insert({1, 2, 3, 4, 5, 6}); + assert(m.size() == 8); + assert(distance(m.begin(), m.end()) == m.size()); + C::const_iterator i = m.cbegin(); + assert(*i == V(1)); + assert(*++i == V(2)); + assert(*++i == V(3)); + assert(*++i == V(4)); + assert(*++i == V(5)); + assert(*++i == V(6)); + assert(*++i == V(8)); + assert(*++i == V(10)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/set/insert_iter_cv.pass.cpp b/libcxx/test/containers/associative/set/insert_iter_cv.pass.cpp index 78ce18337c93..d86d40e89092 100644 --- a/libcxx/test/containers/associative/set/insert_iter_cv.pass.cpp +++ b/libcxx/test/containers/associative/set/insert_iter_cv.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -42,4 +44,30 @@ int main() assert(m.size() == 3); assert(*r == 3); } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> M; + typedef M::iterator R; + M m; + R r = m.insert(m.cend(), M::value_type(2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(*r == 2); + + r = m.insert(m.cend(), M::value_type(1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(*r == 1); + + r = m.insert(m.cend(), M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(*r == 3); + + r = m.insert(m.cend(), M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(*r == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/set/insert_iter_iter.pass.cpp b/libcxx/test/containers/associative/set/insert_iter_iter.pass.cpp index 3bc3a61544da..d99dbe365acd 100644 --- a/libcxx/test/containers/associative/set/insert_iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/set/insert_iter_iter.pass.cpp @@ -18,6 +18,7 @@ #include #include "test_iterators.h" +#include "../../min_allocator.h" int main() { @@ -44,4 +45,29 @@ int main() assert(*next(m.begin()) == 2); assert(*next(m.begin(), 2) == 3); } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> M; + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + M m; + m.insert(input_iterator(ar), + input_iterator(ar + sizeof(ar)/sizeof(ar[0]))); + assert(m.size() == 3); + assert(*m.begin() == 1); + assert(*next(m.begin()) == 2); + assert(*next(m.begin(), 2) == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/set/insert_iter_rv.pass.cpp b/libcxx/test/containers/associative/set/insert_iter_rv.pass.cpp index fdf9f05972c1..cf2dcbf91bb6 100644 --- a/libcxx/test/containers/associative/set/insert_iter_rv.pass.cpp +++ b/libcxx/test/containers/associative/set/insert_iter_rv.pass.cpp @@ -17,6 +17,7 @@ #include #include "../../MoveOnly.h" +#include "../../min_allocator.h" int main() { @@ -45,5 +46,31 @@ int main() assert(m.size() == 3); assert(*r == 3); } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> M; + typedef M::iterator R; + M m; + R r = m.insert(m.cend(), M::value_type(2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(*r == 2); + + r = m.insert(m.cend(), M::value_type(1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(*r == 1); + + r = m.insert(m.cend(), M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(*r == 3); + + r = m.insert(m.cend(), M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(*r == 3); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/set/insert_rv.pass.cpp b/libcxx/test/containers/associative/set/insert_rv.pass.cpp index c7e868d79110..0b58af6cad0e 100644 --- a/libcxx/test/containers/associative/set/insert_rv.pass.cpp +++ b/libcxx/test/containers/associative/set/insert_rv.pass.cpp @@ -17,6 +17,7 @@ #include #include "../../MoveOnly.h" +#include "../../min_allocator.h" int main() { @@ -49,5 +50,35 @@ int main() assert(m.size() == 3); assert(*r.first == 3); } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> M; + typedef std::pair R; + M m; + R r = m.insert(M::value_type(2)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(*r.first == 2); + + r = m.insert(M::value_type(1)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 2); + assert(*r.first == 1); + + r = m.insert(M::value_type(3)); + assert(r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(*r.first == 3); + + r = m.insert(M::value_type(3)); + assert(!r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(*r.first == 3); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/set/iterator.pass.cpp b/libcxx/test/containers/associative/set/iterator.pass.cpp index eb401951aaad..b509aea0cb7e 100644 --- a/libcxx/test/containers/associative/set/iterator.pass.cpp +++ b/libcxx/test/containers/associative/set/iterator.pass.cpp @@ -29,6 +29,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -104,9 +106,89 @@ int main() assert(std::distance(m.cbegin(), m.cend()) == m.size()); assert(std::distance(m.rbegin(), m.rend()) == m.size()); assert(std::distance(m.crbegin(), m.crend()) == m.size()); - std::set::const_iterator i; + std::set::const_iterator i; i = m.begin(); for (int j = 1; j <= m.size(); ++j, ++i) assert(*i == j); } +#if __cplusplus >= 201103L + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3, + 4, + 4, + 4, + 5, + 5, + 5, + 6, + 6, + 6, + 7, + 7, + 7, + 8, + 8, + 8 + }; + std::set, min_allocator> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(std::distance(m.begin(), m.end()) == m.size()); + assert(std::distance(m.rbegin(), m.rend()) == m.size()); + std::set, min_allocator>::iterator i; + i = m.begin(); + std::set, min_allocator>::const_iterator k = i; + assert(i == k); + for (int j = 1; j <= m.size(); ++j, ++i) + assert(*i == j); + } + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3, + 4, + 4, + 4, + 5, + 5, + 5, + 6, + 6, + 6, + 7, + 7, + 7, + 8, + 8, + 8 + }; + const std::set, min_allocator> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(std::distance(m.begin(), m.end()) == m.size()); + assert(std::distance(m.cbegin(), m.cend()) == m.size()); + assert(std::distance(m.rbegin(), m.rend()) == m.size()); + assert(std::distance(m.crbegin(), m.crend()) == m.size()); + std::set, min_allocator>::const_iterator i; + i = m.begin(); + for (int j = 1; j <= m.size(); ++j, ++i) + assert(*i == j); + } +#endif } diff --git a/libcxx/test/containers/associative/set/lower_bound.pass.cpp b/libcxx/test/containers/associative/set/lower_bound.pass.cpp index 8703c8a16b73..072a5879157c 100644 --- a/libcxx/test/containers/associative/set/lower_bound.pass.cpp +++ b/libcxx/test/containers/associative/set/lower_bound.pass.cpp @@ -17,8 +17,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int V; typedef std::set M; { @@ -119,4 +122,109 @@ int main() r = m.lower_bound(20); assert(r == next(m.begin(), 8)); } + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::set, min_allocator> M; + { + typedef M::iterator R; + V ar[] = + { + 5, + 7, + 9, + 11, + 13, + 15, + 17, + 19 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(5); + assert(r == m.begin()); + r = m.lower_bound(7); + assert(r == next(m.begin())); + r = m.lower_bound(9); + assert(r == next(m.begin(), 2)); + r = m.lower_bound(11); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(13); + assert(r == next(m.begin(), 4)); + r = m.lower_bound(15); + assert(r == next(m.begin(), 5)); + r = m.lower_bound(17); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(19); + assert(r == next(m.begin(), 7)); + r = m.lower_bound(4); + assert(r == next(m.begin(), 0)); + r = m.lower_bound(6); + assert(r == next(m.begin(), 1)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 2)); + r = m.lower_bound(10); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(12); + assert(r == next(m.begin(), 4)); + r = m.lower_bound(14); + assert(r == next(m.begin(), 5)); + r = m.lower_bound(16); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(18); + assert(r == next(m.begin(), 7)); + r = m.lower_bound(20); + assert(r == next(m.begin(), 8)); + } + { + typedef M::const_iterator R; + V ar[] = + { + 5, + 7, + 9, + 11, + 13, + 15, + 17, + 19 + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(5); + assert(r == m.begin()); + r = m.lower_bound(7); + assert(r == next(m.begin())); + r = m.lower_bound(9); + assert(r == next(m.begin(), 2)); + r = m.lower_bound(11); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(13); + assert(r == next(m.begin(), 4)); + r = m.lower_bound(15); + assert(r == next(m.begin(), 5)); + r = m.lower_bound(17); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(19); + assert(r == next(m.begin(), 7)); + r = m.lower_bound(4); + assert(r == next(m.begin(), 0)); + r = m.lower_bound(6); + assert(r == next(m.begin(), 1)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 2)); + r = m.lower_bound(10); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(12); + assert(r == next(m.begin(), 4)); + r = m.lower_bound(14); + assert(r == next(m.begin(), 5)); + r = m.lower_bound(16); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(18); + assert(r == next(m.begin(), 7)); + r = m.lower_bound(20); + assert(r == next(m.begin(), 8)); + } + } +#endif } diff --git a/libcxx/test/containers/associative/set/max_size.pass.cpp b/libcxx/test/containers/associative/set/max_size.pass.cpp index 493c78514a8b..b744b9eb16a4 100644 --- a/libcxx/test/containers/associative/set/max_size.pass.cpp +++ b/libcxx/test/containers/associative/set/max_size.pass.cpp @@ -16,9 +16,20 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef std::set M; M m; assert(m.max_size() != 0); + } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> M; + M m; + assert(m.max_size() != 0); + } +#endif } diff --git a/libcxx/test/containers/associative/set/set.cons/assign_initializer_list.pass.cpp b/libcxx/test/containers/associative/set/set.cons/assign_initializer_list.pass.cpp index b37e0d4740ea..26f38e94b19f 100644 --- a/libcxx/test/containers/associative/set/set.cons/assign_initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/set/set.cons/assign_initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::set C; typedef C::value_type V; C m = {10, 8}; @@ -32,5 +35,23 @@ int main() assert(*++i == V(4)); assert(*++i == V(5)); assert(*++i == V(6)); + } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> C; + typedef C::value_type V; + C m = {10, 8}; + m = {1, 2, 3, 4, 5, 6}; + assert(m.size() == 6); + assert(distance(m.begin(), m.end()) == 6); + C::const_iterator i = m.cbegin(); + assert(*i == V(1)); + assert(*++i == V(2)); + assert(*++i == V(3)); + assert(*++i == V(4)); + assert(*++i == V(5)); + assert(*++i == V(6)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/set/set.cons/default.pass.cpp b/libcxx/test/containers/associative/set/set.cons/default.pass.cpp index 955a0d37df4e..300b4fc6873a 100644 --- a/libcxx/test/containers/associative/set/set.cons/default.pass.cpp +++ b/libcxx/test/containers/associative/set/set.cons/default.pass.cpp @@ -16,9 +16,20 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { std::set m; assert(m.empty()); assert(m.begin() == m.end()); + } +#if __cplusplus >= 201103L + { + std::set, min_allocator> m; + assert(m.empty()); + assert(m.begin() == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/set/set.cons/initializer_list.pass.cpp b/libcxx/test/containers/associative/set/set.cons/initializer_list.pass.cpp index badb107ab860..7d981a11a858 100644 --- a/libcxx/test/containers/associative/set/set.cons/initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/set/set.cons/initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::set C; typedef C::value_type V; C m = {1, 2, 3, 4, 5, 6}; @@ -31,5 +34,22 @@ int main() assert(*++i == V(4)); assert(*++i == V(5)); assert(*++i == V(6)); + } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> C; + typedef C::value_type V; + C m = {1, 2, 3, 4, 5, 6}; + assert(m.size() == 6); + assert(distance(m.begin(), m.end()) == 6); + C::const_iterator i = m.cbegin(); + assert(*i == V(1)); + assert(*++i == V(2)); + assert(*++i == V(3)); + assert(*++i == V(4)); + assert(*++i == V(5)); + assert(*++i == V(6)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/set/set.cons/iter_iter.pass.cpp b/libcxx/test/containers/associative/set/set.cons/iter_iter.pass.cpp index ff068503e5ba..3248257fe2a6 100644 --- a/libcxx/test/containers/associative/set/set.cons/iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/set/set.cons/iter_iter.pass.cpp @@ -18,9 +18,11 @@ #include #include "test_iterators.h" +#include "../../../min_allocator.h" int main() { + { typedef int V; V ar[] = { @@ -41,4 +43,29 @@ int main() assert(*m.begin() == 1); assert(*next(m.begin()) == 2); assert(*next(m.begin(), 2) == 3); + } +#if __cplusplus >= 201103L + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + std::set, min_allocator> m(input_iterator(ar), + input_iterator(ar+sizeof(ar)/sizeof(ar[0]))); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == 1); + assert(*next(m.begin()) == 2); + assert(*next(m.begin(), 2) == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/set/set.cons/move.pass.cpp b/libcxx/test/containers/associative/set/set.cons/move.pass.cpp index 350513ab9958..2d1b37f4e077 100644 --- a/libcxx/test/containers/associative/set/set.cons/move.pass.cpp +++ b/libcxx/test/containers/associative/set/set.cons/move.pass.cpp @@ -18,6 +18,7 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -69,5 +70,38 @@ int main() assert(mo.size() == 0); assert(distance(mo.begin(), mo.end()) == 0); } +#if __cplusplus >= 201103L + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + typedef test_compare > C; + typedef min_allocator A; + std::set mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::set m = std::move(mo); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == 1); + assert(*next(m.begin()) == 2); + assert(*next(m.begin(), 2) == 3); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 0); + assert(distance(mo.begin(), mo.end()) == 0); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/set/set.cons/move_assign.pass.cpp b/libcxx/test/containers/associative/set/set.cons/move_assign.pass.cpp index 15bcb6d64e2e..3e82e28d5164 100644 --- a/libcxx/test/containers/associative/set/set.cons/move_assign.pass.cpp +++ b/libcxx/test/containers/associative/set/set.cons/move_assign.pass.cpp @@ -19,6 +19,7 @@ #include "../../../MoveOnly.h" #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -140,5 +141,46 @@ int main() assert(m3.key_comp() == C(5)); assert(m1.empty()); } +#if __cplusplus >= 201103L + { + typedef MoveOnly V; + typedef test_compare > C; + typedef min_allocator A; + typedef std::set M; + typedef std::move_iterator I; + V a1[] = + { + V(1), + V(1), + V(1), + V(2), + V(2), + V(2), + V(3), + V(3), + V(3) + }; + M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A()); + V a2[] = + { + V(1), + V(1), + V(1), + V(2), + V(2), + V(2), + V(3), + V(3), + V(3) + }; + M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A()); + M m3(C(3), A()); + m3 = std::move(m1); + assert(m3 == m2); + assert(m3.get_allocator() == A()); + assert(m3.key_comp() == C(5)); + assert(m1.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/set/set.special/member_swap.pass.cpp b/libcxx/test/containers/associative/set/set.special/member_swap.pass.cpp index 0ac283729ed4..aa38fe03577c 100644 --- a/libcxx/test/containers/associative/set/set.special/member_swap.pass.cpp +++ b/libcxx/test/containers/associative/set/set.special/member_swap.pass.cpp @@ -16,8 +16,11 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { typedef int V; typedef std::set M; { @@ -104,4 +107,95 @@ int main() assert(m1 == m2_save); assert(m2 == m1_save); } + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::set, min_allocator> M; + { + V ar1[] = + { + }; + V ar2[] = + { + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + }; + V ar2[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + 1, + 2, + 3, + 4 + }; + V ar2[] = + { + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + 1, + 2, + 3, + 4 + }; + V ar2[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + } +#endif } diff --git a/libcxx/test/containers/associative/set/size.pass.cpp b/libcxx/test/containers/associative/set/size.pass.cpp index e2083031191e..e1b6b6ce7c8c 100644 --- a/libcxx/test/containers/associative/set/size.pass.cpp +++ b/libcxx/test/containers/associative/set/size.pass.cpp @@ -16,8 +16,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef std::set M; M m; assert(m.size() == 0); @@ -33,4 +36,24 @@ int main() assert(m.size() == 1); m.erase(m.begin()); assert(m.size() == 0); + } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> M; + M m; + assert(m.size() == 0); + m.insert(M::value_type(2)); + assert(m.size() == 1); + m.insert(M::value_type(1)); + assert(m.size() == 2); + m.insert(M::value_type(3)); + assert(m.size() == 3); + m.erase(m.begin()); + assert(m.size() == 2); + m.erase(m.begin()); + assert(m.size() == 1); + m.erase(m.begin()); + assert(m.size() == 0); + } +#endif } diff --git a/libcxx/test/containers/associative/set/types.pass.cpp b/libcxx/test/containers/associative/set/types.pass.cpp index 5a6b2c3d4cd2..04b9ead0381c 100644 --- a/libcxx/test/containers/associative/set/types.pass.cpp +++ b/libcxx/test/containers/associative/set/types.pass.cpp @@ -32,8 +32,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { static_assert((std::is_same::key_type, int>::value), ""); static_assert((std::is_same::value_type, int>::value), ""); static_assert((std::is_same::key_compare, std::less >::value), ""); @@ -45,4 +48,20 @@ int main() static_assert((std::is_same::const_pointer, const int*>::value), ""); static_assert((std::is_same::size_type, std::size_t>::value), ""); static_assert((std::is_same::difference_type, std::ptrdiff_t>::value), ""); + } +#if __cplusplus >= 201103L + { + static_assert((std::is_same, min_allocator>::key_type, int>::value), ""); + static_assert((std::is_same, min_allocator>::value_type, int>::value), ""); + static_assert((std::is_same, min_allocator>::key_compare, std::less >::value), ""); + static_assert((std::is_same, min_allocator>::value_compare, std::less >::value), ""); + static_assert((std::is_same, min_allocator>::allocator_type, min_allocator >::value), ""); + static_assert((std::is_same, min_allocator>::reference, int&>::value), ""); + static_assert((std::is_same, min_allocator>::const_reference, const int&>::value), ""); + static_assert((std::is_same, min_allocator>::pointer, min_pointer>::value), ""); + static_assert((std::is_same, min_allocator>::const_pointer, min_pointer>::value), ""); + static_assert((std::is_same, min_allocator>::size_type, std::size_t>::value), ""); + static_assert((std::is_same, min_allocator>::difference_type, std::ptrdiff_t>::value), ""); + } +#endif } diff --git a/libcxx/test/containers/associative/set/upper_bound.pass.cpp b/libcxx/test/containers/associative/set/upper_bound.pass.cpp index 8f5713308c04..3d000d88e573 100644 --- a/libcxx/test/containers/associative/set/upper_bound.pass.cpp +++ b/libcxx/test/containers/associative/set/upper_bound.pass.cpp @@ -17,8 +17,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int V; typedef std::set M; { @@ -119,4 +122,109 @@ int main() r = m.upper_bound(20); assert(r == next(m.begin(), 8)); } + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::set, min_allocator> M; + { + typedef M::iterator R; + V ar[] = + { + 5, + 7, + 9, + 11, + 13, + 15, + 17, + 19 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(5); + assert(r == next(m.begin(), 1)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 2)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(11); + assert(r == next(m.begin(), 4)); + r = m.upper_bound(13); + assert(r == next(m.begin(), 5)); + r = m.upper_bound(15); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(17); + assert(r == next(m.begin(), 7)); + r = m.upper_bound(19); + assert(r == next(m.begin(), 8)); + r = m.upper_bound(4); + assert(r == next(m.begin(), 0)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 1)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 2)); + r = m.upper_bound(10); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(12); + assert(r == next(m.begin(), 4)); + r = m.upper_bound(14); + assert(r == next(m.begin(), 5)); + r = m.upper_bound(16); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(18); + assert(r == next(m.begin(), 7)); + r = m.upper_bound(20); + assert(r == next(m.begin(), 8)); + } + { + typedef M::const_iterator R; + V ar[] = + { + 5, + 7, + 9, + 11, + 13, + 15, + 17, + 19 + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(5); + assert(r == next(m.begin(), 1)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 2)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(11); + assert(r == next(m.begin(), 4)); + r = m.upper_bound(13); + assert(r == next(m.begin(), 5)); + r = m.upper_bound(15); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(17); + assert(r == next(m.begin(), 7)); + r = m.upper_bound(19); + assert(r == next(m.begin(), 8)); + r = m.upper_bound(4); + assert(r == next(m.begin(), 0)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 1)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 2)); + r = m.upper_bound(10); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(12); + assert(r == next(m.begin(), 4)); + r = m.upper_bound(14); + assert(r == next(m.begin(), 5)); + r = m.upper_bound(16); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(18); + assert(r == next(m.begin(), 7)); + r = m.upper_bound(20); + assert(r == next(m.begin(), 8)); + } + } +#endif } diff --git a/libcxx/test/containers/min_allocator.h b/libcxx/test/containers/min_allocator.h new file mode 100644 index 000000000000..7aa197758a56 --- /dev/null +++ b/libcxx/test/containers/min_allocator.h @@ -0,0 +1,268 @@ +#ifndef MIN_ALLOCATOR_H +#define MIN_ALLOCATOR_H + +#if __cplusplus >= 201103L + +#include + +template class min_pointer; +template class min_pointer; +template <> class min_pointer; +template <> class min_pointer; +template class min_allocator; + +template +bool +operator==(min_pointer x, min_pointer y); + +template <> +class min_pointer +{ + const void* ptr_; +public: + min_pointer() noexcept = default; + min_pointer(std::nullptr_t) : ptr_(nullptr) {} + template + min_pointer(min_pointer p) : ptr_(p.ptr_) {} + + explicit operator bool() const {return ptr_ != nullptr;} + + template friend bool operator==(min_pointer, min_pointer); + template friend class min_pointer; +}; + +template <> +class min_pointer +{ + void* ptr_; +public: + min_pointer() noexcept = default; + min_pointer(std::nullptr_t) : ptr_(nullptr) {} + template ::value + >::type + > + min_pointer(min_pointer p) : ptr_(p.ptr_) {} + + explicit operator bool() const {return ptr_ != nullptr;} + + template friend bool operator==(min_pointer, min_pointer); + template friend class min_pointer; +}; + +template +class min_pointer +{ + T* ptr_; + + explicit min_pointer(T* p) : ptr_(p) {} +public: + min_pointer() noexcept = default; + min_pointer(std::nullptr_t) : ptr_(nullptr) {} + explicit min_pointer(min_pointer p) : ptr_(static_cast(p.ptr_)) {} + + explicit operator bool() const {return ptr_ != nullptr;} + + typedef std::ptrdiff_t difference_type; + typedef T& reference; + typedef T* pointer; + typedef T value_type; + typedef std::random_access_iterator_tag iterator_category; + + reference operator*() const {return *ptr_;} + pointer operator->() const {return ptr_;} + + min_pointer& operator++() {++ptr_; return *this;} + min_pointer operator++(int) {min_pointer tmp(*this); ++ptr_; return tmp;} + + min_pointer& operator--() {--ptr_; return *this;} + min_pointer operator--(int) {min_pointer tmp(*this); --ptr_; return tmp;} + + min_pointer& operator+=(difference_type n) {ptr_ += n; return *this;} + min_pointer& operator-=(difference_type n) {ptr_ -= n; return *this;} + + min_pointer operator+(difference_type n) const + { + min_pointer tmp(*this); + tmp += n; + return tmp; + } + + friend min_pointer operator+(difference_type n, min_pointer x) + { + return x + n; + } + + min_pointer operator-(difference_type n) const + { + min_pointer tmp(*this); + tmp -= n; + return tmp; + } + + friend difference_type operator-(min_pointer x, min_pointer y) + { + return x.ptr_ - y.ptr_; + } + + reference operator[](difference_type n) const {return ptr_[n];} + + friend bool operator< (min_pointer x, min_pointer y) {return x.ptr_ < y.ptr_;} + friend bool operator> (min_pointer x, min_pointer y) {return y < x;} + friend bool operator<=(min_pointer x, min_pointer y) {return !(y < x);} + friend bool operator>=(min_pointer x, min_pointer y) {return !(x < y);} + + static min_pointer pointer_to(T& t) {return min_pointer(std::addressof(t));} + + template friend bool operator==(min_pointer, min_pointer); + template friend class min_pointer; + template friend class min_allocator; +}; + +template +class min_pointer +{ + const T* ptr_; + + explicit min_pointer(const T* p) : ptr_(p) {} +public: + min_pointer() noexcept = default; + min_pointer(std::nullptr_t) : ptr_(nullptr) {} + min_pointer(min_pointer p) : ptr_(p.ptr_) {} + explicit min_pointer(min_pointer p) : ptr_(static_cast(p.ptr_)) {} + + explicit operator bool() const {return ptr_ != nullptr;} + + typedef std::ptrdiff_t difference_type; + typedef const T& reference; + typedef const T* pointer; + typedef const T value_type; + typedef std::random_access_iterator_tag iterator_category; + + reference operator*() const {return *ptr_;} + pointer operator->() const {return ptr_;} + + min_pointer& operator++() {++ptr_; return *this;} + min_pointer operator++(int) {min_pointer tmp(*this); ++ptr_; return tmp;} + + min_pointer& operator--() {--ptr_; return *this;} + min_pointer operator--(int) {min_pointer tmp(*this); --ptr_; return tmp;} + + min_pointer& operator+=(difference_type n) {ptr_ += n; return *this;} + min_pointer& operator-=(difference_type n) {ptr_ -= n; return *this;} + + min_pointer operator+(difference_type n) const + { + min_pointer tmp(*this); + tmp += n; + return tmp; + } + + friend min_pointer operator+(difference_type n, min_pointer x) + { + return x + n; + } + + min_pointer operator-(difference_type n) const + { + min_pointer tmp(*this); + tmp -= n; + return tmp; + } + + friend difference_type operator-(min_pointer x, min_pointer y) + { + return x.ptr_ - y.ptr_; + } + + reference operator[](difference_type n) const {return ptr_[n];} + + friend bool operator< (min_pointer x, min_pointer y) {return x.ptr_ < y.ptr_;} + friend bool operator> (min_pointer x, min_pointer y) {return y < x;} + friend bool operator<=(min_pointer x, min_pointer y) {return !(y < x);} + friend bool operator>=(min_pointer x, min_pointer y) {return !(x < y);} + + static min_pointer pointer_to(const T& t) {return min_pointer(std::addressof(t));} + + template friend bool operator==(min_pointer, min_pointer); + template friend class min_pointer; +}; + +template +inline +bool +operator==(min_pointer x, min_pointer y) +{ + return x.ptr_ == y.ptr_; +} + +template +inline +bool +operator!=(min_pointer x, min_pointer y) +{ + return !(x == y); +} + +template +inline +bool +operator==(min_pointer x, std::nullptr_t) +{ + return !static_cast(x); +} + +template +inline +bool +operator==(std::nullptr_t, min_pointer x) +{ + return !static_cast(x); +} + +template +inline +bool +operator!=(min_pointer x, std::nullptr_t) +{ + return static_cast(x); +} + +template +inline +bool +operator!=(std::nullptr_t, min_pointer x) +{ + return static_cast(x); +} + +template +class min_allocator +{ +public: + typedef T value_type; + typedef min_pointer pointer; + + min_allocator() = default; + template + min_allocator(min_allocator) {} + + pointer allocate(std::ptrdiff_t n) + { + return pointer(static_cast(::operator new(n*sizeof(T)))); + } + + void deallocate(pointer p, std::ptrdiff_t) + { + return ::operator delete(p.ptr_); + } + + friend bool operator==(min_allocator, min_allocator) {return true;} + friend bool operator!=(min_allocator x, min_allocator y) {return !(x == y);} +}; + +#endif // __cplusplus >= 201103L + +#endif // MIN_ALLOCATOR_H