From 3ec1f00b733700a73adda3140e1ca2af551903d6 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Thu, 27 Jun 2013 19:35:32 +0000 Subject: [PATCH] Implement full support for non-pointer pointers in custom allocators for vector. llvm-svn: 185093 --- libcxx/include/__bit_reference | 25 +++-- libcxx/include/iterator | 9 +- libcxx/include/vector | 92 ++++++++----------- libcxx/test/containers/min_allocator.h | 32 ++----- .../vector.bool/assign_copy.pass.cpp | 10 ++ .../assign_initializer_list.pass.cpp | 17 +++- .../vector.bool/assign_move.pass.cpp | 17 ++++ .../sequences/vector.bool/capacity.pass.cpp | 14 +++ .../vector.bool/construct_default.pass.cpp | 7 ++ .../vector.bool/construct_iter_iter.pass.cpp | 8 ++ .../construct_iter_iter_alloc.pass.cpp | 13 +++ .../vector.bool/construct_size.pass.cpp | 5 + .../vector.bool/construct_size_value.pass.cpp | 5 + .../construct_size_value_alloc.pass.cpp | 5 + .../sequences/vector.bool/copy.pass.cpp | 14 +++ .../sequences/vector.bool/copy_alloc.pass.cpp | 14 +++ .../sequences/vector.bool/erase_iter.pass.cpp | 26 ++++++ .../vector.bool/erase_iter_iter.pass.cpp | 34 +++++++ .../vector.bool/initializer_list.pass.cpp | 16 +++- .../initializer_list_alloc.pass.cpp | 18 +++- .../insert_iter_initializer_list.pass.cpp | 26 ++++++ .../insert_iter_iter_iter.pass.cpp | 35 +++++++ .../insert_iter_size_value.pass.cpp | 17 ++++ .../vector.bool/insert_iter_value.pass.cpp | 16 ++++ .../sequences/vector.bool/iterators.pass.cpp | 38 ++++++++ .../sequences/vector.bool/move.pass.cpp | 16 ++++ .../sequences/vector.bool/move_alloc.pass.cpp | 16 ++++ .../op_equal_initializer_list.pass.cpp | 15 +++ .../sequences/vector.bool/push_back.pass.cpp | 18 +++- .../sequences/vector.bool/reserve.pass.cpp | 19 ++++ .../vector.bool/resize_size.pass.cpp | 13 +++ .../vector.bool/resize_size_value.pass.cpp | 18 ++++ .../vector.bool/shrink_to_fit.pass.cpp | 11 +++ .../sequences/vector.bool/swap.pass.cpp | 34 +++++++ .../sequences/vector.bool/types.pass.cpp | 8 +- .../vector.bool/vector_bool.pass.cpp | 16 ++++ .../vector/const_value_type.pass.cpp | 2 + .../sequences/vector/db_back.pass.cpp | 15 +++ .../sequences/vector/db_cback.pass.cpp | 13 +++ .../sequences/vector/db_cfront.pass.cpp | 13 +++ .../sequences/vector/db_cindex.pass.cpp | 14 +++ .../sequences/vector/db_front.pass.cpp | 15 +++ .../sequences/vector/db_index.pass.cpp | 15 +++ .../sequences/vector/db_iterators_1.pass.cpp | 14 +++ .../sequences/vector/db_iterators_2.pass.cpp | 14 +++ .../sequences/vector/db_iterators_3.pass.cpp | 14 +++ .../sequences/vector/db_iterators_4.pass.cpp | 15 +++ .../sequences/vector/db_iterators_5.pass.cpp | 17 ++++ .../sequences/vector/db_iterators_6.pass.cpp | 16 ++++ .../sequences/vector/db_iterators_7.pass.cpp | 16 ++++ .../sequences/vector/db_iterators_8.pass.cpp | 14 +++ .../sequences/vector/iterators.pass.cpp | 66 +++++++++++++ .../sequences/vector/types.pass.cpp | 9 ++ .../vector/vector.capacity/capacity.pass.cpp | 14 +++ .../vector/vector.capacity/reserve.pass.cpp | 18 ++++ .../vector.capacity/resize_size.pass.cpp | 12 +++ .../resize_size_value.pass.cpp | 26 ++++++ .../vector.capacity/shrink_to_fit.pass.cpp | 10 ++ .../vector/vector.capacity/swap.pass.cpp | 13 +++ .../vector/vector.cons/assign_copy.pass.cpp | 10 ++ .../assign_initializer_list.pass.cpp | 15 +++ .../vector/vector.cons/assign_move.pass.cpp | 17 ++++ .../vector.cons/construct_default.pass.cpp | 14 +++ .../vector.cons/construct_iter_iter.pass.cpp | 8 ++ .../construct_iter_iter_alloc.pass.cpp | 15 +++ .../vector.cons/construct_size.pass.cpp | 6 ++ .../vector.cons/construct_size_value.pass.cpp | 4 + .../construct_size_value_alloc.pass.cpp | 4 + .../vector/vector.cons/copy.pass.cpp | 14 +++ .../vector/vector.cons/copy_alloc.pass.cpp | 14 +++ .../vector.cons/initializer_list.pass.cpp | 13 +++ .../initializer_list_alloc.pass.cpp | 14 +++ .../vector/vector.cons/move.pass.cpp | 24 +++++ .../vector/vector.cons/move_alloc.pass.cpp | 16 ++++ .../op_equal_initializer_list.pass.cpp | 15 +++ .../vector/vector.data/data.pass.cpp | 12 +++ .../vector/vector.data/data_const.pass.cpp | 12 +++ .../vector/vector.modifiers/emplace.pass.cpp | 35 +++++++ .../vector.modifiers/emplace_back.pass.cpp | 16 ++++ .../vector.modifiers/emplace_extra.pass.cpp | 19 ++++ .../vector.modifiers/erase_iter.pass.cpp | 27 ++++++ .../vector.modifiers/erase_iter_db1.pass.cpp | 13 +++ .../vector.modifiers/erase_iter_db2.pass.cpp | 14 +++ .../vector.modifiers/erase_iter_iter.pass.cpp | 41 +++++++++ .../erase_iter_iter_db1.pass.cpp | 13 +++ .../erase_iter_iter_db2.pass.cpp | 13 +++ .../erase_iter_iter_db3.pass.cpp | 13 +++ .../erase_iter_iter_db4.pass.cpp | 12 +++ .../insert_iter_initializer_list.pass.cpp | 26 ++++++ .../insert_iter_iter_iter.pass.cpp | 46 ++++++++++ .../insert_iter_rvalue.pass.cpp | 23 +++++ .../insert_iter_size_value.pass.cpp | 37 ++++++++ .../insert_iter_value.pass.cpp | 24 +++++ .../vector/vector.modifiers/pop_back.pass.cpp | 14 +++ .../vector.modifiers/push_back.pass.cpp | 26 ++++++ .../push_back_rvalue.pass.cpp | 26 ++++++ .../vector/vector.special/db_swap_1.pass.cpp | 17 ++++ .../vector/vector.special/swap.pass.cpp | 58 ++++++++++++ 98 files changed, 1721 insertions(+), 91 deletions(-) diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference index 1621deb88834..8ff3bf6d9ee7 100644 --- a/libcxx/include/__bit_reference +++ b/libcxx/include/__bit_reference @@ -333,7 +333,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) } // do middle whole words __storage_type __nw = __n / __bits_per_word; - _VSTD::memset(__first.__seg_, 0, __nw * sizeof(__storage_type)); + _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), 0, __nw * sizeof(__storage_type)); __n -= __nw * __bits_per_word; // do last partial word if (__n > 0) @@ -363,7 +363,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) } // do middle whole words __storage_type __nw = __n / __bits_per_word; - _VSTD::memset(__first.__seg_, -1, __nw * sizeof(__storage_type)); + _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), -1, __nw * sizeof(__storage_type)); __n -= __nw * __bits_per_word; // do last partial word if (__n > 0) @@ -430,7 +430,9 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon // __first.__ctz_ == 0; // do middle words __storage_type __nw = __n / __bits_per_word; - _VSTD::memmove(__result.__seg_, __first.__seg_, __nw * sizeof(__storage_type)); + _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_), + _VSTD::__to_raw_pointer(__first.__seg_), + __nw * sizeof(__storage_type)); __n -= __nw * __bits_per_word; __result.__seg_ += __nw; // do last word @@ -569,7 +571,9 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C __storage_type __nw = __n / __bits_per_word; __result.__seg_ -= __nw; __last.__seg_ -= __nw; - _VSTD::memmove(__result.__seg_, __last.__seg_, __nw * sizeof(__storage_type)); + _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_), + _VSTD::__to_raw_pointer(__last.__seg_), + __nw * sizeof(__storage_type)); __n -= __nw * __bits_per_word; // do last word if (__n > 0) @@ -870,6 +874,7 @@ struct __bit_array { typedef typename _Cp::difference_type difference_type; typedef typename _Cp::__storage_type __storage_type; + typedef typename _Cp::__storage_pointer __storage_pointer; typedef typename _Cp::iterator iterator; static const unsigned __bits_per_word = _Cp::__bits_per_word; static const unsigned _Np = 4; @@ -880,9 +885,15 @@ struct __bit_array _LIBCPP_INLINE_VISIBILITY static difference_type capacity() {return static_cast(_Np * __bits_per_word);} _LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {} - _LIBCPP_INLINE_VISIBILITY iterator begin() {return iterator(__word_, 0);} - _LIBCPP_INLINE_VISIBILITY iterator end() {return iterator(__word_ + __size_ / __bits_per_word, - static_cast(__size_ % __bits_per_word));} + _LIBCPP_INLINE_VISIBILITY iterator begin() + { + return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0); + } + _LIBCPP_INLINE_VISIBILITY iterator end() + { + return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word, + static_cast(__size_ % __bits_per_word)); + } }; template diff --git a/libcxx/include/iterator b/libcxx/include/iterator index 3b078a2a214c..dda053da33bc 100644 --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -1135,7 +1135,14 @@ public: #endif return *__i; } - _LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT {return &(operator*());} + _LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable iterator"); +#endif + return (pointer)&reinterpret_cast(*__i); + } _LIBCPP_INLINE_VISIBILITY __wrap_iter& operator++() _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 diff --git a/libcxx/include/vector b/libcxx/include/vector index e04c2673b2e2..046d92dc91b0 100644 --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -365,12 +365,7 @@ protected: {return static_cast(__end_cap() - __begin_);} _LIBCPP_INLINE_VISIBILITY - void __destruct_at_end(const_pointer __new_last) _NOEXCEPT - {__destruct_at_end(__new_last, false_type());} - _LIBCPP_INLINE_VISIBILITY - void __destruct_at_end(const_pointer __new_last, false_type) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - void __destruct_at_end(const_pointer __new_last, true_type) _NOEXCEPT; + void __destruct_at_end(pointer __new_last) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __vector_base& __c) @@ -437,43 +432,35 @@ private: template _LIBCPP_INLINE_VISIBILITY inline void -__vector_base<_Tp, _Allocator>::__destruct_at_end(const_pointer __new_last, false_type) _NOEXCEPT +__vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT { while (__new_last != __end_) - __alloc_traits::destroy(__alloc(), const_cast(--__end_)); -} - -template -_LIBCPP_INLINE_VISIBILITY inline -void -__vector_base<_Tp, _Allocator>::__destruct_at_end(const_pointer __new_last, true_type) _NOEXCEPT -{ - __end_ = const_cast(__new_last); + __alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_)); } template _LIBCPP_INLINE_VISIBILITY inline __vector_base<_Tp, _Allocator>::__vector_base() _NOEXCEPT_(is_nothrow_default_constructible::value) - : __begin_(0), - __end_(0), - __end_cap_(0) + : __begin_(nullptr), + __end_(nullptr), + __end_cap_(nullptr) { } template _LIBCPP_INLINE_VISIBILITY inline __vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a) - : __begin_(0), - __end_(0), - __end_cap_(0, __a) + : __begin_(nullptr), + __end_(nullptr), + __end_cap_(nullptr, __a) { } template __vector_base<_Tp, _Allocator>::~__vector_base() { - if (__begin_ != 0) + if (__begin_ != nullptr) { clear(); __alloc_traits::deallocate(__alloc(), __begin_, capacity()); @@ -797,7 +784,7 @@ private: _NOEXCEPT_(is_nothrow_move_assignable::value); void __move_assign(vector& __c, false_type); _LIBCPP_INLINE_VISIBILITY - void __destruct_at_end(const_pointer __new_last) _NOEXCEPT + void __destruct_at_end(pointer __new_last) _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 __c_node* __c = __get_db()->__find_c_and_lock(this); @@ -878,11 +865,11 @@ template void vector<_Tp, _Allocator>::deallocate() _NOEXCEPT { - if (this->__begin_ != 0) + if (this->__begin_ != nullptr) { clear(); __alloc_traits::deallocate(this->__alloc(), this->__begin_, capacity()); - this->__begin_ = this->__end_ = this->__end_cap() = 0; + this->__begin_ = this->__end_ = this->__end_cap() = nullptr; } } @@ -1171,7 +1158,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x) this->__begin_ = __x.__begin_; this->__end_ = __x.__end_; this->__end_cap() = __x.__end_cap(); - __x.__begin_ = __x.__end_ = __x.__end_cap() = 0; + __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; } template @@ -1597,7 +1584,8 @@ vector<_Tp, _Allocator>::erase(const_iterator __position) #endif _LIBCPP_ASSERT(__position != end(), "vector::erase(iterator) called with a non-dereferenceable iterator"); - pointer __p = const_cast(&*__position); + difference_type __ps = __position - cbegin(); + pointer __p = this->__begin_ + __ps; iterator __r = __make_iter(__p); this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p)); return __r; @@ -1943,9 +1931,9 @@ template bool vector<_Tp, _Allocator>::__invariants() const { - if (this->__begin_ == 0) + if (this->__begin_ == nullptr) { - if (this->__end_ != 0 || this->__end_cap() != 0) + if (this->__end_ != nullptr || this->__end_cap() != nullptr) return false; } else @@ -2307,7 +2295,7 @@ private: {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast(__pos % __bits_per_word));} _LIBCPP_INLINE_VISIBILITY iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT - {return iterator(const_cast<__storage_pointer>(__p.__seg_), __p.__ctz_);} + {return begin() + (__p - cbegin());} #endif // _LIBCPP_DEBUG _LIBCPP_INLINE_VISIBILITY @@ -2414,11 +2402,11 @@ template void vector::deallocate() _NOEXCEPT { - if (this->__begin_ != 0) + if (this->__begin_ != nullptr) { __storage_traits::deallocate(this->__alloc(), this->__begin_, __cap()); __invalidate_all_iterators(); - this->__begin_ = 0; + this->__begin_ = nullptr; this->__size_ = this->__cap() = 0; } } @@ -2481,7 +2469,7 @@ template _LIBCPP_INLINE_VISIBILITY inline vector::vector() _NOEXCEPT_(is_nothrow_default_constructible::value) - : __begin_(0), + : __begin_(nullptr), __size_(0), __cap_alloc_(0) { @@ -2490,7 +2478,7 @@ vector::vector() template _LIBCPP_INLINE_VISIBILITY inline vector::vector(const allocator_type& __a) - : __begin_(0), + : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { @@ -2498,7 +2486,7 @@ vector::vector(const allocator_type& __a) template vector::vector(size_type __n) - : __begin_(0), + : __begin_(nullptr), __size_(0), __cap_alloc_(0) { @@ -2511,7 +2499,7 @@ vector::vector(size_type __n) template vector::vector(size_type __n, const value_type& __x) - : __begin_(0), + : __begin_(nullptr), __size_(0), __cap_alloc_(0) { @@ -2524,7 +2512,7 @@ vector::vector(size_type __n, const value_type& __x) template vector::vector(size_type __n, const value_type& __x, const allocator_type& __a) - : __begin_(0), + : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { @@ -2540,7 +2528,7 @@ template vector::vector(_InputIterator __first, _InputIterator __last, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value>::type*) - : __begin_(0), + : __begin_(nullptr), __size_(0), __cap_alloc_(0) { @@ -2554,7 +2542,7 @@ vector::vector(_InputIterator __first, _InputIterator __last, } catch (...) { - if (__begin_ != 0) + if (__begin_ != nullptr) __storage_traits::deallocate(__alloc(), __begin_, __cap()); __invalidate_all_iterators(); throw; @@ -2567,7 +2555,7 @@ template vector::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value>::type*) - : __begin_(0), + : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { @@ -2581,7 +2569,7 @@ vector::vector(_InputIterator __first, _InputIterator __last, } catch (...) { - if (__begin_ != 0) + if (__begin_ != nullptr) __storage_traits::deallocate(__alloc(), __begin_, __cap()); __invalidate_all_iterators(); throw; @@ -2593,7 +2581,7 @@ template template vector::vector(_ForwardIterator __first, _ForwardIterator __last, typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*) - : __begin_(0), + : __begin_(nullptr), __size_(0), __cap_alloc_(0) { @@ -2609,7 +2597,7 @@ template template vector::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*) - : __begin_(0), + : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { @@ -2625,7 +2613,7 @@ vector::vector(_ForwardIterator __first, _ForwardIterator __la template vector::vector(initializer_list __il) - : __begin_(0), + : __begin_(nullptr), __size_(0), __cap_alloc_(0) { @@ -2639,7 +2627,7 @@ vector::vector(initializer_list __il) template vector::vector(initializer_list __il, const allocator_type& __a) - : __begin_(0), + : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { @@ -2656,7 +2644,7 @@ vector::vector(initializer_list __il, const alloca template vector::~vector() { - if (__begin_ != 0) + if (__begin_ != nullptr) __storage_traits::deallocate(__alloc(), __begin_, __cap()); #ifdef _LIBCPP_DEBUG __invalidate_all_iterators(); @@ -2665,7 +2653,7 @@ vector::~vector() template vector::vector(const vector& __v) - : __begin_(0), + : __begin_(nullptr), __size_(0), __cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc())) { @@ -2678,7 +2666,7 @@ vector::vector(const vector& __v) template vector::vector(const vector& __v, const allocator_type& __a) - : __begin_(0), + : __begin_(nullptr), __size_(0), __cap_alloc_(0, __a) { @@ -2720,14 +2708,14 @@ vector::vector(vector&& __v) __size_(__v.__size_), __cap_alloc_(__v.__cap_alloc_) { - __v.__begin_ = 0; + __v.__begin_ = nullptr; __v.__size_ = 0; __v.__cap() = 0; } template vector::vector(vector&& __v, const allocator_type& __a) - : __begin_(0), + : __begin_(nullptr), __size_(0), __cap_alloc_(0, __a) { @@ -3123,7 +3111,7 @@ template bool vector::__invariants() const { - if (this->__begin_ == 0) + if (this->__begin_ == nullptr) { if (this->__size_ != 0 || this->__cap() != 0) return false; diff --git a/libcxx/test/containers/min_allocator.h b/libcxx/test/containers/min_allocator.h index 7aa197758a56..c0d28e5faa2a 100644 --- a/libcxx/test/containers/min_allocator.h +++ b/libcxx/test/containers/min_allocator.h @@ -11,10 +11,6 @@ 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 { @@ -27,7 +23,8 @@ public: explicit operator bool() const {return ptr_ != nullptr;} - template friend bool operator==(min_pointer, min_pointer); + friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;} + friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);} template friend class min_pointer; }; @@ -48,7 +45,8 @@ public: explicit operator bool() const {return ptr_ != nullptr;} - template friend bool operator==(min_pointer, min_pointer); + friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;} + friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);} template friend class min_pointer; }; @@ -116,7 +114,8 @@ public: static min_pointer pointer_to(T& t) {return min_pointer(std::addressof(t));} - template friend bool operator==(min_pointer, min_pointer); + friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;} + friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);} template friend class min_pointer; template friend class min_allocator; }; @@ -186,26 +185,11 @@ public: static min_pointer pointer_to(const T& t) {return min_pointer(std::addressof(t));} - template friend bool operator==(min_pointer, min_pointer); + friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;} + friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);} 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 diff --git a/libcxx/test/containers/sequences/vector.bool/assign_copy.pass.cpp b/libcxx/test/containers/sequences/vector.bool/assign_copy.pass.cpp index d7db57db8622..7cf927b75531 100644 --- a/libcxx/test/containers/sequences/vector.bool/assign_copy.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/assign_copy.pass.cpp @@ -14,6 +14,7 @@ #include #include #include "../../test_allocator.h" +#include "../../min_allocator.h" int main() { @@ -31,4 +32,13 @@ int main() assert(l2 == l); assert(l2.get_allocator() == other_allocator(5)); } +#if __cplusplus >= 201103L + { + std::vector > l(3, 2, min_allocator()); + std::vector > l2(l, min_allocator()); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == min_allocator()); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/assign_initializer_list.pass.cpp b/libcxx/test/containers/sequences/vector.bool/assign_initializer_list.pass.cpp index 14da56134728..2cf929704746 100644 --- a/libcxx/test/containers/sequences/vector.bool/assign_initializer_list.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/assign_initializer_list.pass.cpp @@ -14,15 +14,30 @@ #include #include +#include "../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS - std::vector d; + { + std::vector d; d.assign({true, false, false, true}); assert(d.size() == 4); assert(d[0] == true); assert(d[1] == false); assert(d[2] == false); assert(d[3] == true); + } +#if __cplusplus >= 201103L + { + std::vector> d; + d.assign({true, false, false, true}); + assert(d.size() == 4); + assert(d[0] == true); + assert(d[1] == false); + assert(d[2] == false); + assert(d[3] == true); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/vector.bool/assign_move.pass.cpp b/libcxx/test/containers/sequences/vector.bool/assign_move.pass.cpp index ca4f1d88b113..5edd3137c5f5 100644 --- a/libcxx/test/containers/sequences/vector.bool/assign_move.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/assign_move.pass.cpp @@ -14,6 +14,7 @@ #include #include #include "../../test_allocator.h" +#include "../../min_allocator.h" int main() { @@ -60,5 +61,21 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } +#if __cplusplus >= 201103L + { + std::vector > l(min_allocator{}); + std::vector > lo(min_allocator{}); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2(min_allocator{}); + l2 = std::move(l); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == lo.get_allocator()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/vector.bool/capacity.pass.cpp b/libcxx/test/containers/sequences/vector.bool/capacity.pass.cpp index 4feb3d978c76..87c98987dbc1 100644 --- a/libcxx/test/containers/sequences/vector.bool/capacity.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/capacity.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -27,4 +29,16 @@ int main() v.push_back(0); assert(v.capacity() >= 101); } +#if __cplusplus >= 201103L + { + std::vector> v; + assert(v.capacity() == 0); + } + { + std::vector> v(100); + assert(v.capacity() >= 100); + v.push_back(0); + assert(v.capacity() >= 101); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/construct_default.pass.cpp b/libcxx/test/containers/sequences/vector.bool/construct_default.pass.cpp index 4a8785a4d28d..fa396abddb7f 100644 --- a/libcxx/test/containers/sequences/vector.bool/construct_default.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/construct_default.pass.cpp @@ -16,6 +16,7 @@ #include #include "../../test_allocator.h" +#include "../../min_allocator.h" template void @@ -43,4 +44,10 @@ int main() test0 >(); test1 > >(test_allocator(3)); } +#if __cplusplus >= 201103L + { + test0> >(); + test1 > >(min_allocator()); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/construct_iter_iter.pass.cpp b/libcxx/test/containers/sequences/vector.bool/construct_iter_iter.pass.cpp index e2c01ee4d9ff..3225d8732ae4 100644 --- a/libcxx/test/containers/sequences/vector.bool/construct_iter_iter.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/construct_iter_iter.pass.cpp @@ -16,6 +16,7 @@ #include #include "test_iterators.h" +#include "../../min_allocator.h" template void @@ -37,4 +38,11 @@ int main() test >(bidirectional_iterator(a), bidirectional_iterator(an)); test >(random_access_iterator(a), random_access_iterator(an)); test >(a, an); +#if __cplusplus >= 201103L + test> >(input_iterator(a), input_iterator(an)); + test> >(forward_iterator(a), forward_iterator(an)); + test> >(bidirectional_iterator(a), bidirectional_iterator(an)); + test> >(random_access_iterator(a), random_access_iterator(an)); + test> >(a, an); +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp b/libcxx/test/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp index 70932b114b9b..12f1caec4b0d 100644 --- a/libcxx/test/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp @@ -17,6 +17,7 @@ #include #include "test_iterators.h" +#include "../../min_allocator.h" template void @@ -33,10 +34,22 @@ int main() { bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; bool* an = a + sizeof(a)/sizeof(a[0]); + { std::allocator alloc; test >(input_iterator(a), input_iterator(an), alloc); test >(forward_iterator(a), forward_iterator(an), alloc); test >(bidirectional_iterator(a), bidirectional_iterator(an), alloc); test >(random_access_iterator(a), random_access_iterator(an), alloc); test >(a, an, alloc); + } +#if __cplusplus >= 201103L + { + min_allocator alloc; + test> >(input_iterator(a), input_iterator(an), alloc); + test> >(forward_iterator(a), forward_iterator(an), alloc); + test> >(bidirectional_iterator(a), bidirectional_iterator(an), alloc); + test> >(random_access_iterator(a), random_access_iterator(an), alloc); + test> >(a, an, alloc); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/construct_size.pass.cpp b/libcxx/test/containers/sequences/vector.bool/construct_size.pass.cpp index a1e952740ea1..0bbd36273f23 100644 --- a/libcxx/test/containers/sequences/vector.bool/construct_size.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/construct_size.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../min_allocator.h" + template void test(typename C::size_type n) @@ -30,4 +32,7 @@ test(typename C::size_type n) int main() { test >(50); +#if __cplusplus >= 201103L + test> >(50); +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/construct_size_value.pass.cpp b/libcxx/test/containers/sequences/vector.bool/construct_size_value.pass.cpp index f84678ab4b8e..dc950a26c26d 100644 --- a/libcxx/test/containers/sequences/vector.bool/construct_size_value.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/construct_size_value.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../min_allocator.h" + template void test(typename C::size_type n, const typename C::value_type& x) @@ -29,4 +31,7 @@ test(typename C::size_type n, const typename C::value_type& x) int main() { test >(50, 3); +#if __cplusplus >= 201103L + test> >(50, 3); +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp b/libcxx/test/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp index 0add99b74ab3..5e0b22af19ce 100644 --- a/libcxx/test/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../min_allocator.h" + template void test(typename C::size_type n, const typename C::value_type& x, @@ -31,4 +33,7 @@ test(typename C::size_type n, const typename C::value_type& x, int main() { test >(50, 3, std::allocator()); +#if __cplusplus >= 201103L + test> >(50, 3, min_allocator()); +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/copy.pass.cpp b/libcxx/test/containers/sequences/vector.bool/copy.pass.cpp index 82e9fe1ceeda..f0e2c7980ef7 100644 --- a/libcxx/test/containers/sequences/vector.bool/copy.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/copy.pass.cpp @@ -15,6 +15,7 @@ #include #include #include "../../test_allocator.h" +#include "../../min_allocator.h" template void @@ -48,4 +49,17 @@ int main() assert(v2.get_allocator() == other_allocator(-2)); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if __cplusplus >= 201103L + { + bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; + bool* an = a + sizeof(a)/sizeof(a[0]); + test(std::vector>(a, an)); + } + { + std::vector > v(3, 2, min_allocator()); + std::vector > v2 = v; + assert(v2 == v); + assert(v2.get_allocator() == v.get_allocator()); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/copy_alloc.pass.cpp b/libcxx/test/containers/sequences/vector.bool/copy_alloc.pass.cpp index fc3edcb0bb80..58e71ddca02c 100644 --- a/libcxx/test/containers/sequences/vector.bool/copy_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/copy_alloc.pass.cpp @@ -14,6 +14,7 @@ #include #include #include "../../test_allocator.h" +#include "../../min_allocator.h" template void @@ -45,4 +46,17 @@ int main() assert(l2 == l); assert(l2.get_allocator() == other_allocator(3)); } +#if __cplusplus >= 201103L + { + int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; + int* an = a + sizeof(a)/sizeof(a[0]); + test(std::vector>(a, an), min_allocator()); + } + { + std::vector > l(3, 2, min_allocator()); + std::vector > l2(l, min_allocator()); + assert(l2 == l); + assert(l2.get_allocator() == min_allocator()); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/erase_iter.pass.cpp b/libcxx/test/containers/sequences/vector.bool/erase_iter.pass.cpp index 29aacebe18ad..776b43ec4d73 100644 --- a/libcxx/test/containers/sequences/vector.bool/erase_iter.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/erase_iter.pass.cpp @@ -15,9 +15,12 @@ #include #include +#include "../../min_allocator.h" + int main() { bool a1[] = {1, 0, 1}; + { std::vector l1(a1, a1+3); std::vector::const_iterator i = l1.begin(); ++i; @@ -36,4 +39,27 @@ int main() assert(j == l1.end()); assert(l1.size() == 0); assert(distance(l1.begin(), l1.end()) == 0); + } +#if __cplusplus >= 201103L + { + std::vector> l1(a1, a1+3); + std::vector>::const_iterator i = l1.begin(); + ++i; + std::vector>::iterator j = l1.erase(i); + assert(l1.size() == 2); + assert(distance(l1.begin(), l1.end()) == 2); + assert(*j == true); + assert(*l1.begin() == 1); + assert(*next(l1.begin()) == true); + j = l1.erase(j); + assert(j == l1.end()); + assert(l1.size() == 1); + assert(distance(l1.begin(), l1.end()) == 1); + assert(*l1.begin() == true); + j = l1.erase(l1.begin()); + assert(j == l1.end()); + assert(l1.size() == 0); + assert(distance(l1.begin(), l1.end()) == 0); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/erase_iter_iter.pass.cpp b/libcxx/test/containers/sequences/vector.bool/erase_iter_iter.pass.cpp index d35603b835e2..8778c32d7246 100644 --- a/libcxx/test/containers/sequences/vector.bool/erase_iter_iter.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/erase_iter_iter.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../min_allocator.h" + int main() { bool a1[] = {1, 0, 1}; @@ -48,4 +50,36 @@ int main() assert(distance(l1.cbegin(), l1.cend()) == 0); assert(i == l1.begin()); } +#if __cplusplus >= 201103L + { + std::vector> l1(a1, a1+3); + std::vector>::iterator i = l1.erase(l1.cbegin(), l1.cbegin()); + assert(l1.size() == 3); + assert(distance(l1.cbegin(), l1.cend()) == 3); + assert(i == l1.begin()); + } + { + std::vector> l1(a1, a1+3); + std::vector>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin())); + assert(l1.size() == 2); + assert(distance(l1.cbegin(), l1.cend()) == 2); + assert(i == l1.begin()); + assert((l1 == std::vector>(a1+1, a1+3))); + } + { + std::vector> l1(a1, a1+3); + std::vector>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2)); + assert(l1.size() == 1); + assert(distance(l1.cbegin(), l1.cend()) == 1); + assert(i == l1.begin()); + assert((l1 == std::vector>(a1+2, a1+3))); + } + { + std::vector> l1(a1, a1+3); + std::vector>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3)); + assert(l1.size() == 0); + assert(distance(l1.cbegin(), l1.cend()) == 0); + assert(i == l1.begin()); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/initializer_list.pass.cpp b/libcxx/test/containers/sequences/vector.bool/initializer_list.pass.cpp index 04d94e077dd4..7c1a5de61abd 100644 --- a/libcxx/test/containers/sequences/vector.bool/initializer_list.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/initializer_list.pass.cpp @@ -14,14 +14,28 @@ #include #include +#include "../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS - std::vector d = {true, false, false, true}; + { + std::vector d = {true, false, false, true}; assert(d.size() == 4); assert(d[0] == true); assert(d[1] == false); assert(d[2] == false); assert(d[3] == true); + } +#if __cplusplus >= 201103L + { + std::vector> d = {true, false, false, true}; + assert(d.size() == 4); + assert(d[0] == true); + assert(d[1] == false); + assert(d[2] == false); + assert(d[3] == true); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp b/libcxx/test/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp index f8b2ee6b72b0..19b5b57fe15e 100644 --- a/libcxx/test/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp @@ -15,16 +15,30 @@ #include #include "../../test_allocator.h" +#include "../../min_allocator.h" int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS - std::vector> d({true, false, false, true}, test_allocator(3)); - assert(d.get_allocator() == test_allocator(3)); + { + std::vector> d({true, false, false, true}, test_allocator(3)); + assert(d.get_allocator() == test_allocator(3)); assert(d.size() == 4); assert(d[0] == true); assert(d[1] == false); assert(d[2] == false); assert(d[3] == true); + } +#if __cplusplus >= 201103L + { + std::vector> d({true, false, false, true}, min_allocator()); + assert(d.get_allocator() == min_allocator()); + assert(d.size() == 4); + assert(d[0] == true); + assert(d[1] == false); + assert(d[2] == false); + assert(d[3] == true); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp b/libcxx/test/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp index c0b4334fa5de..4865b2891422 100644 --- a/libcxx/test/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp @@ -14,9 +14,12 @@ #include #include +#include "../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { std::vector d(10, true); std::vector::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false}); assert(d.size() == 14); @@ -35,5 +38,28 @@ int main() assert(d[11] == true); assert(d[12] == true); assert(d[13] == true); + } +#if __cplusplus >= 201103L + { + std::vector> d(10, true); + std::vector>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false}); + assert(d.size() == 14); + assert(i == d.begin() + 2); + assert(d[0] == true); + assert(d[1] == true); + assert(d[2] == false); + assert(d[3] == true); + assert(d[4] == true); + assert(d[5] == false); + assert(d[6] == true); + assert(d[7] == true); + assert(d[8] == true); + assert(d[9] == true); + assert(d[10] == true); + assert(d[11] == true); + assert(d[12] == true); + assert(d[13] == true); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp b/libcxx/test/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp index 6d150cdd0fef..5099ebc2e143 100644 --- a/libcxx/test/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp @@ -16,6 +16,7 @@ #include #include #include "test_iterators.h" +#include "../../min_allocator.h" int main() { @@ -51,4 +52,38 @@ int main() for (; j < 105; ++j) assert(v[j] == 0); } +#if __cplusplus >= 201103L + { + std::vector> v(100); + bool a[] = {1, 0, 0, 1, 1}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::vector>::iterator i = v.insert(v.cbegin() + 10, input_iterator(a), + input_iterator(a+N)); + assert(v.size() == 100 + N); + assert(i == v.begin() + 10); + int j; + for (j = 0; j < 10; ++j) + assert(v[j] == 0); + for (int k = 0; k < N; ++j, ++k) + assert(v[j] == a[k]); + for (; j < 105; ++j) + assert(v[j] == 0); + } + { + std::vector> v(100); + bool a[] = {1, 0, 0, 1, 1}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::vector>::iterator i = v.insert(v.cbegin() + 10, forward_iterator(a), + forward_iterator(a+N)); + assert(v.size() == 100 + N); + assert(i == v.begin() + 10); + int j; + for (j = 0; j < 10; ++j) + assert(v[j] == 0); + for (int k = 0; k < N; ++j, ++k) + assert(v[j] == a[k]); + for (; j < 105; ++j) + assert(v[j] == 0); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp b/libcxx/test/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp index 09817c2de064..9d49816c7d13 100644 --- a/libcxx/test/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -30,4 +32,19 @@ int main() for (++j; j < 105; ++j) assert(v[j] == 0); } +#if __cplusplus >= 201103L + { + std::vector> v(100); + std::vector>::iterator i = v.insert(v.cbegin() + 10, 5, 1); + assert(v.size() == 105); + assert(i == v.begin() + 10); + int j; + for (j = 0; j < 10; ++j) + assert(v[j] == 0); + for (; j < 15; ++j) + assert(v[j] == 1); + for (++j; j < 105; ++j) + assert(v[j] == 0); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/insert_iter_value.pass.cpp b/libcxx/test/containers/sequences/vector.bool/insert_iter_value.pass.cpp index 203a4bde35af..37bdebcb14ab 100644 --- a/libcxx/test/containers/sequences/vector.bool/insert_iter_value.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/insert_iter_value.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -29,4 +31,18 @@ int main() for (++j; j < 101; ++j) assert(v[j] == 0); } +#if __cplusplus >= 201103L + { + std::vector> v(100); + std::vector>::iterator i = v.insert(v.cbegin() + 10, 1); + assert(v.size() == 101); + assert(i == v.begin() + 10); + int j; + for (j = 0; j < 10; ++j) + assert(v[j] == 0); + assert(v[j] == 1); + for (++j; j < 101; ++j) + assert(v[j] == 0); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/iterators.pass.cpp b/libcxx/test/containers/sequences/vector.bool/iterators.pass.cpp index 45b524c424a6..65a6c1317a6e 100644 --- a/libcxx/test/containers/sequences/vector.bool/iterators.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/iterators.pass.cpp @@ -20,6 +20,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -56,4 +58,40 @@ int main() C::iterator i; C::const_iterator j; } +#if __cplusplus >= 201103L + { + typedef bool T; + typedef std::vector> C; + C c; + C::iterator i = c.begin(); + C::iterator j = c.end(); + assert(std::distance(i, j) == 0); + assert(i == j); + } + { + typedef bool T; + typedef std::vector> C; + const C c; + C::const_iterator i = c.begin(); + C::const_iterator j = c.end(); + assert(std::distance(i, j) == 0); + assert(i == j); + } + { + typedef bool T; + typedef std::vector> C; + C c; + C::const_iterator i = c.cbegin(); + C::const_iterator j = c.cend(); + assert(std::distance(i, j) == 0); + assert(i == j); + assert(i == c.end()); + } + { + typedef bool T; + typedef std::vector> C; + C::iterator i; + C::const_iterator j; + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/move.pass.cpp b/libcxx/test/containers/sequences/vector.bool/move.pass.cpp index b99048ef03ba..49d8e2378834 100644 --- a/libcxx/test/containers/sequences/vector.bool/move.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/move.pass.cpp @@ -14,6 +14,7 @@ #include #include #include "../../test_allocator.h" +#include "../../min_allocator.h" int main() { @@ -44,5 +45,20 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } +#if __cplusplus >= 201103L + { + std::vector > l(min_allocator{}); + std::vector > lo(min_allocator{}); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2 = std::move(l); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == lo.get_allocator()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/vector.bool/move_alloc.pass.cpp b/libcxx/test/containers/sequences/vector.bool/move_alloc.pass.cpp index f51f454e0955..2b890d72ca23 100644 --- a/libcxx/test/containers/sequences/vector.bool/move_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/move_alloc.pass.cpp @@ -14,6 +14,7 @@ #include #include #include "../../test_allocator.h" +#include "../../min_allocator.h" int main() { @@ -57,5 +58,20 @@ int main() assert(!l.empty()); assert(l2.get_allocator() == other_allocator(4)); } +#if __cplusplus >= 201103L + { + std::vector > l(min_allocator{}); + std::vector > lo(min_allocator{}); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2(std::move(l), min_allocator()); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == min_allocator()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp b/libcxx/test/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp index ca786a6240a6..6f201770dbed 100644 --- a/libcxx/test/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp @@ -14,9 +14,12 @@ #include #include +#include "../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { std::vector d; d = {true, false, false, true}; assert(d.size() == 4); @@ -24,5 +27,17 @@ int main() assert(d[1] == false); assert(d[2] == false); assert(d[3] == true); + } +#if __cplusplus >= 201103L + { + std::vector> d; + d = {true, false, false, true}; + assert(d.size() == 4); + assert(d[0] == true); + assert(d[1] == false); + assert(d[2] == false); + assert(d[3] == true); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/vector.bool/push_back.pass.cpp b/libcxx/test/containers/sequences/vector.bool/push_back.pass.cpp index dd380457814f..21b3907b36a7 100644 --- a/libcxx/test/containers/sequences/vector.bool/push_back.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/push_back.pass.cpp @@ -15,12 +15,14 @@ #include #include +#include "../../min_allocator.h" + int main() { { bool a[] = {0, 1, 1, 0, 1, 0, 0}; const unsigned N = sizeof(a)/sizeof(a[0]); - std::vector c; + std::vector c; for (unsigned i = 0; i < N; ++i) { c.push_back(a[i]); @@ -29,4 +31,18 @@ int main() assert(c[j] == a[j]); } } +#if __cplusplus >= 201103L + { + bool a[] = {0, 1, 1, 0, 1, 0, 0}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::vector> c; + for (unsigned i = 0; i < N; ++i) + { + c.push_back(a[i]); + assert(c.size() == i+1); + for (int j = 0; j < c.size(); ++j) + assert(c[j] == a[j]); + } + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/reserve.pass.cpp b/libcxx/test/containers/sequences/vector.bool/reserve.pass.cpp index 21867b3786d3..4e7fbeffebef 100644 --- a/libcxx/test/containers/sequences/vector.bool/reserve.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/reserve.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -32,4 +34,21 @@ int main() assert(v.size() == 100); assert(v.capacity() >= 150); } +#if __cplusplus >= 201103L + { + std::vector> v; + v.reserve(10); + assert(v.capacity() >= 10); + } + { + std::vector> v(100); + assert(v.capacity() >= 100); + v.reserve(50); + assert(v.size() == 100); + assert(v.capacity() >= 100); + v.reserve(150); + assert(v.size() == 100); + assert(v.capacity() >= 150); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/resize_size.pass.cpp b/libcxx/test/containers/sequences/vector.bool/resize_size.pass.cpp index 44a8345c3a3b..17032458118a 100644 --- a/libcxx/test/containers/sequences/vector.bool/resize_size.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/resize_size.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -26,4 +28,15 @@ int main() assert(v.size() == 200); assert(v.capacity() >= 200); } +#if __cplusplus >= 201103L + { + std::vector> v(100); + v.resize(50); + assert(v.size() == 50); + assert(v.capacity() >= 100); + v.resize(200); + assert(v.size() == 200); + assert(v.capacity() >= 200); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/resize_size_value.pass.cpp b/libcxx/test/containers/sequences/vector.bool/resize_size_value.pass.cpp index 1e283f51aa73..1413f5cd022d 100644 --- a/libcxx/test/containers/sequences/vector.bool/resize_size_value.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/resize_size_value.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -31,4 +33,20 @@ int main() for (unsigned i = 50; i < 200; ++i) assert(v[i] == 1); } +#if __cplusplus >= 201103L + { + std::vector> v(100); + v.resize(50, 1); + assert(v.size() == 50); + assert(v.capacity() >= 100); + assert((v == std::vector>(50))); + v.resize(200, 1); + assert(v.size() == 200); + assert(v.capacity() >= 200); + for (unsigned i = 0; i < 50; ++i) + assert(v[i] == 0); + for (unsigned i = 50; i < 200; ++i) + assert(v[i] == 1); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/shrink_to_fit.pass.cpp b/libcxx/test/containers/sequences/vector.bool/shrink_to_fit.pass.cpp index 69662721900c..0b4cf4937cbd 100644 --- a/libcxx/test/containers/sequences/vector.bool/shrink_to_fit.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/shrink_to_fit.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -24,4 +26,13 @@ int main() assert(v.capacity() >= 101); assert(v.size() >= 101); } +#if __cplusplus >= 201103L + { + std::vector> v(100); + v.push_back(1); + v.shrink_to_fit(); + assert(v.capacity() >= 101); + assert(v.size() >= 101); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/swap.pass.cpp b/libcxx/test/containers/sequences/vector.bool/swap.pass.cpp index 5d0f0af129e7..ce5a10e7b687 100644 --- a/libcxx/test/containers/sequences/vector.bool/swap.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/swap.pass.cpp @@ -15,6 +15,7 @@ #include #include #include "../../test_allocator.h" +#include "../../min_allocator.h" int main() { @@ -61,4 +62,37 @@ int main() assert(v[0] == false); assert(v[1] == true); } +#if __cplusplus >= 201103L + { + std::vector> v1(100); + std::vector> v2(200); + v1.swap(v2); + assert(v1.size() == 200); + assert(v1.capacity() >= 200); + assert(v2.size() == 100); + assert(v2.capacity() >= 100); + } + { + typedef min_allocator A; + std::vector v1(100, true, A()); + std::vector v2(200, false, A()); + swap(v1, v2); + assert(v1.size() == 200); + assert(v1.capacity() >= 200); + assert(v2.size() == 100); + assert(v2.capacity() >= 100); + assert(v1.get_allocator() == A()); + assert(v2.get_allocator() == A()); + } + { + std::vector> v(2); + std::vector>::reference r1 = v[0]; + std::vector>::reference r2 = v[1]; + r1 = true; + using std::swap; + swap(r1, r2); + assert(v[0] == false); + assert(v[1] == true); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/types.pass.cpp b/libcxx/test/containers/sequences/vector.bool/types.pass.cpp index 9055a200eb8a..ef33d04219c9 100644 --- a/libcxx/test/containers/sequences/vector.bool/types.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/types.pass.cpp @@ -33,6 +33,7 @@ #include "../../test_allocator.h" #include "../../Copyable.h" +#include "../../min_allocator.h" template void @@ -43,8 +44,8 @@ test() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::size_type>::value), ""); + static_assert((std::is_same::difference_type>::value), ""); static_assert((std::is_same< typename std::iterator_traits::iterator_category, std::random_access_iterator_tag>::value), ""); @@ -65,4 +66,7 @@ int main() test >(); static_assert((std::is_same::allocator_type, std::allocator >::value), ""); +#if __cplusplus >= 201103L + test >(); +#endif } diff --git a/libcxx/test/containers/sequences/vector.bool/vector_bool.pass.cpp b/libcxx/test/containers/sequences/vector.bool/vector_bool.pass.cpp index 0835250322e9..e2bc48a8da8c 100644 --- a/libcxx/test/containers/sequences/vector.bool/vector_bool.pass.cpp +++ b/libcxx/test/containers/sequences/vector.bool/vector_bool.pass.cpp @@ -22,8 +22,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef std::vector T; typedef std::hash H; static_assert((std::is_base_of, @@ -32,4 +35,17 @@ int main() T vb(std::begin(ba), std::end(ba)); H h; assert(h(vb) != 0); + } +#if __cplusplus >= 201103L + { + typedef std::vector> T; + typedef std::hash H; + static_assert((std::is_base_of, + H>::value), ""); + bool ba[] = {true, false, true, true, false}; + T vb(std::begin(ba), std::end(ba)); + H h; + assert(h(vb) != 0); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/const_value_type.pass.cpp b/libcxx/test/containers/sequences/vector/const_value_type.pass.cpp index 7953fb334e80..e16e439dec4d 100644 --- a/libcxx/test/containers/sequences/vector/const_value_type.pass.cpp +++ b/libcxx/test/containers/sequences/vector/const_value_type.pass.cpp @@ -16,5 +16,7 @@ int main() { +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS std::vector v = {1, 2, 3}; +#endif } diff --git a/libcxx/test/containers/sequences/vector/db_back.pass.cpp b/libcxx/test/containers/sequences/vector/db_back.pass.cpp index b28af8b2607d..0893ba7a40d9 100644 --- a/libcxx/test/containers/sequences/vector/db_back.pass.cpp +++ b/libcxx/test/containers/sequences/vector/db_back.pass.cpp @@ -21,8 +21,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int T; typedef std::vector C; C c(1); @@ -30,6 +33,18 @@ int main() c.clear(); assert(c.back() == 0); assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + C c(1); + assert(c.back() == 0); + c.clear(); + assert(c.back() == 0); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/db_cback.pass.cpp b/libcxx/test/containers/sequences/vector/db_cback.pass.cpp index 18f0630791b6..de52ec2e4cf7 100644 --- a/libcxx/test/containers/sequences/vector/db_cback.pass.cpp +++ b/libcxx/test/containers/sequences/vector/db_cback.pass.cpp @@ -21,13 +21,26 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int T; typedef std::vector C; const C c; assert(c.back() == 0); assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + const C c; + assert(c.back() == 0); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/db_cfront.pass.cpp b/libcxx/test/containers/sequences/vector/db_cfront.pass.cpp index 9712a39863ad..e0d9b9506271 100644 --- a/libcxx/test/containers/sequences/vector/db_cfront.pass.cpp +++ b/libcxx/test/containers/sequences/vector/db_cfront.pass.cpp @@ -21,13 +21,26 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int T; typedef std::vector C; const C c; assert(c.front() == 0); assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + const C c; + assert(c.front() == 0); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/db_cindex.pass.cpp b/libcxx/test/containers/sequences/vector/db_cindex.pass.cpp index ad330433594d..c96fa3da381f 100644 --- a/libcxx/test/containers/sequences/vector/db_cindex.pass.cpp +++ b/libcxx/test/containers/sequences/vector/db_cindex.pass.cpp @@ -21,14 +21,28 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int T; typedef std::vector C; const C c(1); assert(c[0] == 0); assert(c[1] == 0); assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + const C c(1); + assert(c[0] == 0); + assert(c[1] == 0); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/db_front.pass.cpp b/libcxx/test/containers/sequences/vector/db_front.pass.cpp index 4892e2858779..fb48c9d477aa 100644 --- a/libcxx/test/containers/sequences/vector/db_front.pass.cpp +++ b/libcxx/test/containers/sequences/vector/db_front.pass.cpp @@ -21,8 +21,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int T; typedef std::vector C; C c(1); @@ -30,6 +33,18 @@ int main() c.clear(); assert(c.front() == 0); assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + C c(1); + assert(c.front() == 0); + c.clear(); + assert(c.front() == 0); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/db_index.pass.cpp b/libcxx/test/containers/sequences/vector/db_index.pass.cpp index 05b0bc48c56c..f09f731e237b 100644 --- a/libcxx/test/containers/sequences/vector/db_index.pass.cpp +++ b/libcxx/test/containers/sequences/vector/db_index.pass.cpp @@ -21,8 +21,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int T; typedef std::vector C; C c(1); @@ -30,6 +33,18 @@ int main() c.clear(); assert(c[0] == 0); assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + C c(1); + assert(c[0] == 0); + c.clear(); + assert(c[0] == 0); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/db_iterators_1.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_1.pass.cpp index fbcb40f614d0..1ef4a27a8a6e 100644 --- a/libcxx/test/containers/sequences/vector/db_iterators_1.pass.cpp +++ b/libcxx/test/containers/sequences/vector/db_iterators_1.pass.cpp @@ -21,14 +21,28 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int T; typedef std::vector C; C c1; C c2; bool b = c1.begin() != c2.begin(); assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + C c1; + C c2; + bool b = c1.begin() != c2.begin(); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/db_iterators_2.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_2.pass.cpp index 616ee5bb7e83..436726c673e5 100644 --- a/libcxx/test/containers/sequences/vector/db_iterators_2.pass.cpp +++ b/libcxx/test/containers/sequences/vector/db_iterators_2.pass.cpp @@ -21,14 +21,28 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int T; typedef std::vector C; C c1; C c2; bool b = c1.begin() < c2.begin(); assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + C c1; + C c2; + bool b = c1.begin() < c2.begin(); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/db_iterators_3.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_3.pass.cpp index 1ef27cf5308c..ffd96d941aa9 100644 --- a/libcxx/test/containers/sequences/vector/db_iterators_3.pass.cpp +++ b/libcxx/test/containers/sequences/vector/db_iterators_3.pass.cpp @@ -21,14 +21,28 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int T; typedef std::vector C; C c1; C c2; int i = c1.begin() - c2.begin(); assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + C c1; + C c2; + int i = c1.begin() - c2.begin(); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/db_iterators_4.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_4.pass.cpp index 4d60bd9b8f6d..fbfae85eebb8 100644 --- a/libcxx/test/containers/sequences/vector/db_iterators_4.pass.cpp +++ b/libcxx/test/containers/sequences/vector/db_iterators_4.pass.cpp @@ -21,8 +21,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int T; typedef std::vector C; C c(1); @@ -30,6 +33,18 @@ int main() assert(i[0] == 0); assert(i[1] == 0); assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + C c(1); + C::iterator i = c.begin(); + assert(i[0] == 0); + assert(i[1] == 0); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/db_iterators_5.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_5.pass.cpp index bb3bf059bfce..9ca5cbbd764b 100644 --- a/libcxx/test/containers/sequences/vector/db_iterators_5.pass.cpp +++ b/libcxx/test/containers/sequences/vector/db_iterators_5.pass.cpp @@ -21,8 +21,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int T; typedef std::vector C; C c(1); @@ -32,6 +35,20 @@ int main() i = c.begin(); i += 2; assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + C c(1); + C::iterator i = c.begin(); + i += 1; + assert(i == c.end()); + i = c.begin(); + i += 2; + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/db_iterators_6.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_6.pass.cpp index 24db88d4f643..d08506b4d3e5 100644 --- a/libcxx/test/containers/sequences/vector/db_iterators_6.pass.cpp +++ b/libcxx/test/containers/sequences/vector/db_iterators_6.pass.cpp @@ -21,8 +21,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int T; typedef std::vector C; C c(1); @@ -31,6 +34,19 @@ int main() assert(i == c.begin()); --i; assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + C c(1); + C::iterator i = c.end(); + --i; + assert(i == c.begin()); + --i; + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/db_iterators_7.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_7.pass.cpp index 709af3a852a9..98c6d8bc4cfe 100644 --- a/libcxx/test/containers/sequences/vector/db_iterators_7.pass.cpp +++ b/libcxx/test/containers/sequences/vector/db_iterators_7.pass.cpp @@ -21,8 +21,11 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int T; typedef std::vector C; C c(1); @@ -31,6 +34,19 @@ int main() assert(i == c.end()); ++i; assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + C c(1); + C::iterator i = c.begin(); + ++i; + assert(i == c.end()); + ++i; + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/db_iterators_8.pass.cpp b/libcxx/test/containers/sequences/vector/db_iterators_8.pass.cpp index 178240aa8a45..b8353948c8c2 100644 --- a/libcxx/test/containers/sequences/vector/db_iterators_8.pass.cpp +++ b/libcxx/test/containers/sequences/vector/db_iterators_8.pass.cpp @@ -21,14 +21,28 @@ #include #include +#include "../../min_allocator.h" + int main() { + { typedef int T; typedef std::vector C; C c(1); C::iterator i = c.end(); T j = *i; assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + C c(1); + C::iterator i = c.end(); + T j = *i; + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/iterators.pass.cpp b/libcxx/test/containers/sequences/vector/iterators.pass.cpp index 9ebd20bd6bb6..fbd40298d19b 100644 --- a/libcxx/test/containers/sequences/vector/iterators.pass.cpp +++ b/libcxx/test/containers/sequences/vector/iterators.pass.cpp @@ -20,6 +20,14 @@ #include #include +#include "../../min_allocator.h" + +struct A +{ + int first; + int second; +}; + int main() { { @@ -69,4 +77,62 @@ int main() C::iterator i; C::const_iterator j; } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + C c; + C::iterator i = c.begin(); + C::iterator j = c.end(); + assert(std::distance(i, j) == 0); + assert(i == j); + } + { + typedef int T; + typedef std::vector> C; + const C c; + C::const_iterator i = c.begin(); + C::const_iterator j = c.end(); + assert(std::distance(i, j) == 0); + assert(i == j); + } + { + typedef int T; + typedef std::vector> C; + C c; + C::const_iterator i = c.cbegin(); + C::const_iterator j = c.cend(); + assert(std::distance(i, j) == 0); + assert(i == j); + assert(i == c.end()); + } + { + typedef int T; + typedef std::vector> C; + const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + C c(std::begin(t), std::end(t)); + C::iterator i = c.begin(); + assert(*i == 0); + ++i; + assert(*i == 1); + *i = 10; + assert(*i == 10); + assert(std::distance(c.begin(), c.end()) == 10); + } + { + typedef int T; + typedef std::vector> C; + C::iterator i; + C::const_iterator j; + } + { + typedef A T; + typedef std::vector> C; + C c = {A{1, 2}}; + C::iterator i = c.begin(); + i->first = 3; + C::const_iterator j = i; + assert(j->first == 3); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/types.pass.cpp b/libcxx/test/containers/sequences/vector/types.pass.cpp index 12c5350c9b1b..5e1dc9b9ec4a 100644 --- a/libcxx/test/containers/sequences/vector/types.pass.cpp +++ b/libcxx/test/containers/sequences/vector/types.pass.cpp @@ -35,6 +35,7 @@ #include "../../test_allocator.h" #include "../../Copyable.h" +#include "../../min_allocator.h" template void @@ -72,4 +73,12 @@ int main() test >(); static_assert((std::is_same::allocator_type, std::allocator >::value), ""); +#if __cplusplus >= 201103L + static_assert((std::is_same>::value_type, int>::value), ""); + static_assert((std::is_same>::allocator_type, min_allocator >::value), ""); + static_assert((std::is_same>::reference, int&>::value), ""); + static_assert((std::is_same>::const_reference, const int&>::value), ""); + static_assert((std::is_same>::pointer, min_pointer>::value), ""); + static_assert((std::is_same>::const_pointer, min_pointer>::value), ""); +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.capacity/capacity.pass.cpp b/libcxx/test/containers/sequences/vector/vector.capacity/capacity.pass.cpp index da4c1cae5a8a..861ec9ab78d1 100644 --- a/libcxx/test/containers/sequences/vector/vector.capacity/capacity.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.capacity/capacity.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -26,4 +28,16 @@ int main() v.push_back(0); assert(v.capacity() > 101); } +#if __cplusplus >= 201103L + { + std::vector> v; + assert(v.capacity() == 0); + } + { + std::vector> v(100); + assert(v.capacity() == 100); + v.push_back(0); + assert(v.capacity() > 101); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.capacity/reserve.pass.cpp b/libcxx/test/containers/sequences/vector/vector.capacity/reserve.pass.cpp index 450fc907fb52..4b91711dfc34 100644 --- a/libcxx/test/containers/sequences/vector/vector.capacity/reserve.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.capacity/reserve.pass.cpp @@ -14,6 +14,7 @@ #include #include #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -42,4 +43,21 @@ int main() assert(v.size() == 100); assert(v.capacity() == 150); } +#if __cplusplus >= 201103L + { + std::vector> v; + v.reserve(10); + assert(v.capacity() >= 10); + } + { + std::vector> v(100); + assert(v.capacity() == 100); + v.reserve(50); + assert(v.size() == 100); + assert(v.capacity() == 100); + v.reserve(150); + assert(v.size() == 100); + assert(v.capacity() == 150); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.capacity/resize_size.pass.cpp b/libcxx/test/containers/sequences/vector/vector.capacity/resize_size.pass.cpp index f373026aa2c5..7a3389fd0fae 100644 --- a/libcxx/test/containers/sequences/vector/vector.capacity/resize_size.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.capacity/resize_size.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../stack_allocator.h" #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -57,4 +58,15 @@ int main() assert(v.capacity() >= 200); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + std::vector> v(100); + v.resize(50); + assert(v.size() == 50); + assert(v.capacity() == 100); + v.resize(200); + assert(v.size() == 200); + assert(v.capacity() >= 200); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp b/libcxx/test/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp index 41042ba95bfe..fb267617820c 100644 --- a/libcxx/test/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp @@ -14,6 +14,7 @@ #include #include #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -40,4 +41,29 @@ int main() assert(v.size() == 200); assert(v.capacity() >= 200); } +#if __cplusplus >= 201103L + { + std::vector> v(100); + v.resize(50, 1); + assert(v.size() == 50); + assert(v.capacity() == 100); + assert((v == std::vector>(50))); + v.resize(200, 1); + assert(v.size() == 200); + assert(v.capacity() >= 200); + for (unsigned i = 0; i < 50; ++i) + assert(v[i] == 0); + for (unsigned i = 50; i < 200; ++i) + assert(v[i] == 1); + } + { + std::vector> v(100); + v.resize(50, 1); + assert(v.size() == 50); + assert(v.capacity() == 100); + v.resize(200, 1); + assert(v.size() == 200); + assert(v.capacity() >= 200); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp b/libcxx/test/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp index 896026de17bc..7a8d0c71a388 100644 --- a/libcxx/test/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp @@ -14,6 +14,7 @@ #include #include #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -40,4 +41,13 @@ int main() assert(v.size() == 101); } #endif +#if __cplusplus >= 201103L + { + std::vector> v(100); + v.push_back(1); + v.shrink_to_fit(); + assert(v.capacity() == 101); + assert(v.size() == 101); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.capacity/swap.pass.cpp b/libcxx/test/containers/sequences/vector/vector.capacity/swap.pass.cpp index a2673ead935a..8152802bfa5d 100644 --- a/libcxx/test/containers/sequences/vector/vector.capacity/swap.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.capacity/swap.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -25,4 +27,15 @@ int main() assert(v2.size() == 100); assert(v2.capacity() == 100); } +#if __cplusplus >= 201103L + { + std::vector> v1(100); + std::vector> v2(200); + v1.swap(v2); + assert(v1.size() == 200); + assert(v1.capacity() == 200); + assert(v2.size() == 100); + assert(v2.capacity() == 100); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/assign_copy.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/assign_copy.pass.cpp index f80040f3a33e..9623d0f328af 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/assign_copy.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/assign_copy.pass.cpp @@ -14,6 +14,7 @@ #include #include #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -31,4 +32,13 @@ int main() assert(l2 == l); assert(l2.get_allocator() == other_allocator(5)); } +#if __cplusplus >= 201103L + { + std::vector > l(3, 2, min_allocator()); + std::vector > l2(l, min_allocator()); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == min_allocator()); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp index 55080561a3a6..13c3e4920137 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp @@ -14,9 +14,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { std::vector d; d.assign({3, 4, 5, 6}); assert(d.size() == 4); @@ -24,5 +27,17 @@ int main() assert(d[1] == 4); assert(d[2] == 5); assert(d[3] == 6); + } +#if __cplusplus >= 201103L + { + std::vector> d; + d.assign({3, 4, 5, 6}); + assert(d.size() == 4); + assert(d[0] == 3); + assert(d[1] == 4); + assert(d[2] == 5); + assert(d[3] == 6); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/assign_move.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/assign_move.pass.cpp index 433ba996db07..1a29db939ee0 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/assign_move.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/assign_move.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../MoveOnly.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -61,5 +62,21 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } +#if __cplusplus >= 201103L + { + std::vector > l(min_allocator{}); + std::vector > lo(min_allocator{}); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2(min_allocator{}); + l2 = std::move(l); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == lo.get_allocator()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/construct_default.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/construct_default.pass.cpp index 0c55fd6528d0..ec66c0d8545e 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/construct_default.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/construct_default.pass.cpp @@ -17,6 +17,7 @@ #include "../../../test_allocator.h" #include "../../../NotConstructible.h" #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" template void @@ -51,4 +52,17 @@ int main() std::vector > v; assert(v.empty()); } +#if __cplusplus >= 201103L + { + test0> >(); + test0> >(); + test1 > >(min_allocator{}); + test1 > > + (min_allocator{}); + } + { + std::vector > v; + assert(v.empty()); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp index 9c9b88e73dd4..6841319920e1 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp @@ -16,6 +16,7 @@ #include "test_iterators.h" #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" template void @@ -43,4 +44,11 @@ int main() test > >(bidirectional_iterator(a), bidirectional_iterator(an)); test > >(random_access_iterator(a), random_access_iterator(an)); test > >(a, an); +#if __cplusplus >= 201103L + test> >(input_iterator(a), input_iterator(an)); + test> >(forward_iterator(a), forward_iterator(an)); + test> >(bidirectional_iterator(a), bidirectional_iterator(an)); + test> >(random_access_iterator(a), random_access_iterator(an)); + test >(a, an); +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp index 17bba911e32f..e386297cf7a3 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp @@ -17,6 +17,7 @@ #include "test_iterators.h" #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" template void @@ -31,6 +32,7 @@ test(Iterator first, Iterator last, const typename C::allocator_type& a) int main() { + { int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; int* an = a + sizeof(a)/sizeof(a[0]); std::allocator alloc; @@ -39,4 +41,17 @@ int main() test >(bidirectional_iterator(a), bidirectional_iterator(an), alloc); test >(random_access_iterator(a), random_access_iterator(an), alloc); test >(a, an, alloc); + } +#if __cplusplus >= 201103L + { + int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; + int* an = a + sizeof(a)/sizeof(a[0]); + min_allocator alloc; + test> >(input_iterator(a), input_iterator(an), alloc); + test> >(forward_iterator(a), forward_iterator(an), alloc); + test> >(bidirectional_iterator(a), bidirectional_iterator(an), alloc); + test> >(random_access_iterator(a), random_access_iterator(an), alloc); + test> >(a, an, alloc); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp index 9be5eb65c87c..c49b6686d165 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../DefaultOnly.h" +#include "../../../min_allocator.h" template void @@ -35,4 +36,9 @@ int main() test >(50); test >(500); assert(DefaultOnly::count == 0); +#if __cplusplus >= 201103L + test> >(50); + test> >(500); + assert(DefaultOnly::count == 0); +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp index e71197b95ea9..35adaed2fb1a 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" template void @@ -31,4 +32,7 @@ int main() { test >(50, 3); test > >(50, 5); +#if __cplusplus >= 201103L + test> >(50, 3); +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp index e6a015747ddb..27da426f82c2 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp @@ -13,6 +13,7 @@ #include #include +#include "../../../min_allocator.h" template void @@ -30,4 +31,7 @@ test(typename C::size_type n, const typename C::value_type& x, int main() { test >(50, 3, std::allocator()); +#if __cplusplus >= 201103L + test> >(50, 3, min_allocator()); +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/copy.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/copy.pass.cpp index 4dc2ab7b4eec..34008ae3bde2 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/copy.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/copy.pass.cpp @@ -14,6 +14,7 @@ #include #include #include "../../../test_allocator.h" +#include "../../../min_allocator.h" template void @@ -47,4 +48,17 @@ int main() assert(v2.get_allocator() == other_allocator(-2)); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if __cplusplus >= 201103L + { + int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; + int* an = a + sizeof(a)/sizeof(a[0]); + test(std::vector>(a, an)); + } + { + std::vector > v(3, 2, min_allocator()); + std::vector > v2 = v; + assert(v2 == v); + assert(v2.get_allocator() == v.get_allocator()); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp index 47fc0081b86b..22fca55f74cd 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp @@ -14,6 +14,7 @@ #include #include #include "../../../test_allocator.h" +#include "../../../min_allocator.h" template void @@ -45,4 +46,17 @@ int main() assert(l2 == l); assert(l2.get_allocator() == other_allocator(3)); } +#if __cplusplus >= 201103L + { + int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; + int* an = a + sizeof(a)/sizeof(a[0]); + test(std::vector>(a, an), min_allocator()); + } + { + std::vector > l(3, 2, min_allocator()); + std::vector > l2(l, min_allocator()); + assert(l2 == l); + assert(l2.get_allocator() == min_allocator()); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/initializer_list.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/initializer_list.pass.cpp index 5c33ad7d13c4..938c03611573 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/initializer_list.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/initializer_list.pass.cpp @@ -13,15 +13,28 @@ #include #include +#include "../../../min_allocator.h" int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { std::vector d = {3, 4, 5, 6}; assert(d.size() == 4); assert(d[0] == 3); assert(d[1] == 4); assert(d[2] == 5); assert(d[3] == 6); + } +#if __cplusplus >= 201103L + { + std::vector> d = {3, 4, 5, 6}; + assert(d.size() == 4); + assert(d[0] == 3); + assert(d[1] == 4); + assert(d[2] == 5); + assert(d[3] == 6); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp index f99352627d79..12d27c67454c 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp @@ -15,10 +15,12 @@ #include #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { std::vector> d({3, 4, 5, 6}, test_allocator(3)); assert(d.get_allocator() == test_allocator(3)); assert(d.size() == 4); @@ -26,5 +28,17 @@ int main() assert(d[1] == 4); assert(d[2] == 5); assert(d[3] == 6); + } +#if __cplusplus >= 201103L + { + std::vector> d({3, 4, 5, 6}, min_allocator()); + assert(d.get_allocator() == min_allocator()); + assert(d.size() == 4); + assert(d[0] == 3); + assert(d[1] == 4); + assert(d[2] == 5); + assert(d[3] == 6); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/move.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/move.pass.cpp index b0364058eeda..0514f31a5a2f 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/move.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/move.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../MoveOnly.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -53,5 +54,28 @@ int main() std::vector::iterator j = c2.erase(i); assert(*j == 3); } +#if __cplusplus >= 201103L + { + std::vector > l(min_allocator{}); + std::vector > lo(min_allocator{}); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2 = std::move(l); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == lo.get_allocator()); + } + { + int a1[] = {1, 3, 7, 9, 10}; + std::vector> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::vector>::const_iterator i = c1.begin(); + std::vector> c2 = std::move(c1); + std::vector>::iterator j = c2.erase(i); + assert(*j == 3); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/move_alloc.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/move_alloc.pass.cpp index f2a63d113ef3..2f590dcdf895 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/move_alloc.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/move_alloc.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../MoveOnly.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -58,5 +59,20 @@ int main() assert(!l.empty()); assert(l2.get_allocator() == other_allocator(4)); } +#if __cplusplus >= 201103L + { + std::vector > l(min_allocator{}); + std::vector > lo(min_allocator{}); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2(std::move(l), min_allocator()); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == min_allocator()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp b/libcxx/test/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp index 8b28fe584df4..916ddaa9fc86 100644 --- a/libcxx/test/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp @@ -14,9 +14,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { std::vector d; d = {3, 4, 5, 6}; assert(d.size() == 4); @@ -24,5 +27,17 @@ int main() assert(d[1] == 4); assert(d[2] == 5); assert(d[3] == 6); + } +#if __cplusplus >= 201103L + { + std::vector> d; + d = {3, 4, 5, 6}; + assert(d.size() == 4); + assert(d[0] == 3); + assert(d[1] == 4); + assert(d[2] == 5); + assert(d[3] == 6); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/vector/vector.data/data.pass.cpp b/libcxx/test/containers/sequences/vector/vector.data/data.pass.cpp index 0359ff989b82..9ae324332a64 100644 --- a/libcxx/test/containers/sequences/vector/vector.data/data.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.data/data.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -24,4 +26,14 @@ int main() std::vector v(100); assert(v.data() == &v.front()); } +#if __cplusplus >= 201103L + { + std::vector> v; + assert(v.data() == 0); + } + { + std::vector> v(100); + assert(v.data() == &v.front()); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.data/data_const.pass.cpp b/libcxx/test/containers/sequences/vector/vector.data/data_const.pass.cpp index 60232f2bda80..77e8b83af99d 100644 --- a/libcxx/test/containers/sequences/vector/vector.data/data_const.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.data/data_const.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -24,4 +26,14 @@ int main() const std::vector v(100); assert(v.data() == &v.front()); } +#if __cplusplus >= 201103L + { + const std::vector> v; + assert(v.data() == 0); + } + { + const std::vector> v(100); + assert(v.data() == &v.front()); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp index d85b8f2235e2..fe2bf1b15e60 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp @@ -18,6 +18,7 @@ #include #include #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -114,5 +115,39 @@ int main() assert(false); } #endif +#if __cplusplus >= 201103L + { + std::vector> c; + std::vector>::iterator i = c.emplace(c.cbegin(), 2, 3.5); + assert(i == c.begin()); + assert(c.size() == 1); + assert(c.front().geti() == 2); + assert(c.front().getd() == 3.5); + i = c.emplace(c.cend(), 3, 4.5); + assert(i == c.end()-1); + assert(c.size() == 2); + assert(c.front().geti() == 2); + assert(c.front().getd() == 3.5); + assert(c.back().geti() == 3); + assert(c.back().getd() == 4.5); + i = c.emplace(c.cbegin()+1, 4, 6.5); + assert(i == c.begin()+1); + assert(c.size() == 3); + assert(c.front().geti() == 2); + assert(c.front().getd() == 3.5); + assert(c[1].geti() == 4); + assert(c[1].getd() == 6.5); + assert(c.back().geti() == 3); + assert(c.back().getd() == 4.5); + } +#if _LIBCPP_DEBUG2 >= 1 + { + std::vector> c1; + std::vector> c2; + std::vector>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5); + assert(false); + } +#endif +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp index 5b6aae7e65c0..1d024d452d60 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp @@ -14,6 +14,7 @@ #include #include #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -80,5 +81,20 @@ int main() assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); } +#if __cplusplus >= 201103L + { + std::vector> c; + c.emplace_back(2, 3.5); + assert(c.size() == 1); + assert(c.front().geti() == 2); + assert(c.front().getd() == 3.5); + c.emplace_back(3, 4.5); + assert(c.size() == 2); + assert(c.front().geti() == 2); + assert(c.front().getd() == 3.5); + assert(c.back().geti() == 3); + assert(c.back().getd() == 4.5); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp index 26a394f06a61..d70320716bbf 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp @@ -13,6 +13,9 @@ #include #include + +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -30,5 +33,21 @@ int main() v.emplace(v.begin(), v.back()); assert(v[0] == 3); } +#if __cplusplus >= 201103L + { + std::vector> v; + v.reserve(3); + v = { 1, 2, 3 }; + v.emplace(v.begin(), v.back()); + assert(v[0] == 3); + } + { + std::vector> v; + v.reserve(4); + v = { 1, 2, 3 }; + v.emplace(v.begin(), v.back()); + assert(v[0] == 3); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp index 6489c2ba673e..6fcd189bdacb 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp @@ -14,8 +14,11 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { int a1[] = {1, 2, 3}; std::vector l1(a1, a1+3); std::vector::const_iterator i = l1.begin(); @@ -35,4 +38,28 @@ int main() assert(j == l1.end()); assert(l1.size() == 0); assert(distance(l1.begin(), l1.end()) == 0); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::vector> l1(a1, a1+3); + std::vector>::const_iterator i = l1.begin(); + ++i; + std::vector>::iterator j = l1.erase(i); + assert(l1.size() == 2); + assert(distance(l1.begin(), l1.end()) == 2); + assert(*j == 3); + assert(*l1.begin() == 1); + assert(*next(l1.begin()) == 3); + j = l1.erase(j); + assert(j == l1.end()); + assert(l1.size() == 1); + assert(distance(l1.begin(), l1.end()) == 1); + assert(*l1.begin() == 1); + j = l1.erase(l1.begin()); + assert(j == l1.end()); + assert(l1.size() == 0); + assert(distance(l1.begin(), l1.end()) == 0); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp index 81f1354bb539..a49d59057b8a 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp @@ -20,13 +20,26 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { int a1[] = {1, 2, 3}; std::vector l1(a1, a1+3); std::vector::const_iterator i = l1.end(); l1.erase(i); assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::vector> l1(a1, a1+3); + std::vector>::const_iterator i = l1.end(); + l1.erase(i); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp index 15fa5a39c2c1..0450f3df2f26 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp @@ -20,14 +20,28 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { int a1[] = {1, 2, 3}; std::vector l1(a1, a1+3); std::vector l2(a1, a1+3); std::vector::const_iterator i = l2.begin(); l1.erase(i); assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::vector> l1(a1, a1+3); + std::vector> l2(a1, a1+3); + std::vector>::const_iterator i = l2.begin(); + l1.erase(i); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp index 5fdcb8775b58..8a382edba671 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { int a1[] = {1, 2, 3}; @@ -54,4 +56,43 @@ int main() assert(outer[0].size() == 1); assert(outer[1].size() == 1); } +#if __cplusplus >= 201103L + { + std::vector> l1(a1, a1+3); + std::vector>::iterator i = l1.erase(l1.cbegin(), l1.cbegin()); + assert(l1.size() == 3); + assert(distance(l1.cbegin(), l1.cend()) == 3); + assert(i == l1.begin()); + } + { + std::vector> l1(a1, a1+3); + std::vector>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin())); + assert(l1.size() == 2); + assert(distance(l1.cbegin(), l1.cend()) == 2); + assert(i == l1.begin()); + assert((l1 == std::vector>(a1+1, a1+3))); + } + { + std::vector> l1(a1, a1+3); + std::vector>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2)); + assert(l1.size() == 1); + assert(distance(l1.cbegin(), l1.cend()) == 1); + assert(i == l1.begin()); + assert((l1 == std::vector>(a1+2, a1+3))); + } + { + std::vector> l1(a1, a1+3); + std::vector>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3)); + assert(l1.size() == 0); + assert(distance(l1.cbegin(), l1.cend()) == 0); + assert(i == l1.begin()); + } + { + std::vector>, min_allocator>>> outer(2, std::vector>(1)); + outer.erase(outer.begin(), outer.begin()); + assert(outer.size() == 2); + assert(outer[0].size() == 1); + assert(outer[1].size() == 1); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp index 846e111f8db7..465953b40672 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp @@ -20,13 +20,26 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { int a1[] = {1, 2, 3}; std::vector l1(a1, a1+3); std::vector l2(a1, a1+3); std::vector::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1); assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::vector> l1(a1, a1+3); + std::vector> l2(a1, a1+3); + std::vector>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp index 04cb5dc7d858..f0484e1c3a17 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp @@ -20,13 +20,26 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { int a1[] = {1, 2, 3}; std::vector l1(a1, a1+3); std::vector l2(a1, a1+3); std::vector::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1); assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::vector> l1(a1, a1+3); + std::vector> l2(a1, a1+3); + std::vector>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp index a614a11dd552..040f95f3c28c 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp @@ -20,13 +20,26 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { int a1[] = {1, 2, 3}; std::vector l1(a1, a1+3); std::vector l2(a1, a1+3); std::vector::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1); assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::vector> l1(a1, a1+3); + std::vector> l2(a1, a1+3); + std::vector>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp index 9818024b1cb2..573570d942e3 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp @@ -20,12 +20,24 @@ #include #include +#include "../../../min_allocator.h" + int main() { + { int a1[] = {1, 2, 3}; std::vector l1(a1, a1+3); std::vector::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin()); assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::vector> l1(a1, a1+3); + std::vector>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin()); + assert(false); + } +#endif } #else diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp index 65247bf7916f..caba7844390b 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp @@ -14,9 +14,12 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { std::vector d(10, 1); std::vector::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6}); assert(d.size() == 14); @@ -35,5 +38,28 @@ int main() assert(d[11] == 1); assert(d[12] == 1); assert(d[13] == 1); + } +#if __cplusplus >= 201103L + { + std::vector> d(10, 1); + std::vector>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6}); + assert(d.size() == 14); + assert(i == d.begin() + 2); + assert(d[0] == 1); + assert(d[1] == 1); + assert(d[2] == 3); + assert(d[3] == 4); + assert(d[4] == 5); + assert(d[5] == 6); + assert(d[6] == 1); + assert(d[7] == 1); + assert(d[8] == 1); + assert(d[9] == 1); + assert(d[10] == 1); + assert(d[11] == 1); + assert(d[12] == 1); + assert(d[13] == 1); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp index 9f68aefc8b98..a7f8865de0a8 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp @@ -20,6 +20,7 @@ #include #include "../../../stack_allocator.h" #include "test_iterators.h" +#include "../../../min_allocator.h" int main() { @@ -98,4 +99,49 @@ int main() assert(false); } #endif +#if __cplusplus >= 201103L + { + std::vector> v(100); + int a[] = {1, 2, 3, 4, 5}; + const int N = sizeof(a)/sizeof(a[0]); + std::vector>::iterator i = v.insert(v.cbegin() + 10, input_iterator(a), + input_iterator(a+N)); + assert(v.size() == 100 + N); + assert(i == v.begin() + 10); + int j; + for (j = 0; j < 10; ++j) + assert(v[j] == 0); + for (int k = 0; k < N; ++j, ++k) + assert(v[j] == a[k]); + for (; j < 105; ++j) + assert(v[j] == 0); + } + { + std::vector> v(100); + int a[] = {1, 2, 3, 4, 5}; + const int N = sizeof(a)/sizeof(a[0]); + std::vector>::iterator i = v.insert(v.cbegin() + 10, forward_iterator(a), + forward_iterator(a+N)); + assert(v.size() == 100 + N); + assert(i == v.begin() + 10); + int j; + for (j = 0; j < 10; ++j) + assert(v[j] == 0); + for (int k = 0; k < N; ++j, ++k) + assert(v[j] == a[k]); + for (; j < 105; ++j) + assert(v[j] == 0); + } +#if _LIBCPP_DEBUG2 >= 1 + { + std::vector> v(100); + std::vector> v2(100); + int a[] = {1, 2, 3, 4, 5}; + const int N = sizeof(a)/sizeof(a[0]); + std::vector>::iterator i = v.insert(v2.cbegin() + 10, input_iterator(a), + input_iterator(a+N)); + assert(false); + } +#endif +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp index e34dc367e26b..be2289118f50 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp @@ -19,6 +19,7 @@ #include #include "../../../stack_allocator.h" #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -55,5 +56,27 @@ int main() assert(false); } #endif +#if __cplusplus >= 201103L + { + std::vector> v(100); + std::vector>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3)); + assert(v.size() == 101); + assert(i == v.begin() + 10); + int j; + for (j = 0; j < 10; ++j) + assert(v[j] == MoveOnly()); + assert(v[j] == MoveOnly(3)); + for (++j; j < 101; ++j) + assert(v[j] == MoveOnly()); + } +#if _LIBCPP_DEBUG2 >= 1 + { + std::vector> v1(3); + std::vector> v2(3); + v1.insert(v2.begin(), 4); + assert(false); + } +#endif +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp index ed940572c906..bdfffdbbe9ff 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp @@ -18,6 +18,7 @@ #include #include #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -55,4 +56,40 @@ int main() assert(false); } #endif +#if __cplusplus >= 201103L + { + std::vector> v(100); + std::vector>::iterator i = v.insert(v.cbegin() + 10, 5, 1); + assert(v.size() == 105); + assert(i == v.begin() + 10); + int j; + for (j = 0; j < 10; ++j) + assert(v[j] == 0); + for (; j < 15; ++j) + assert(v[j] == 1); + for (++j; j < 105; ++j) + assert(v[j] == 0); + } + { + std::vector> v(100); + std::vector>::iterator i = v.insert(v.cbegin() + 10, 5, 1); + assert(v.size() == 105); + assert(i == v.begin() + 10); + int j; + for (j = 0; j < 10; ++j) + assert(v[j] == 0); + for (; j < 15; ++j) + assert(v[j] == 1); + for (++j; j < 105; ++j) + assert(v[j] == 0); + } +#if _LIBCPP_DEBUG2 >= 1 + { + std::vector> c1(100); + std::vector> c2; + std::vector>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1); + assert(false); + } +#endif +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp index 5bc87fddd050..08e18cc44d1b 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp @@ -18,6 +18,7 @@ #include #include #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -54,4 +55,27 @@ int main() assert(false); } #endif +#if __cplusplus >= 201103L + { + std::vector> v(100); + std::vector>::iterator i = v.insert(v.cbegin() + 10, 1); + assert(v.size() == 101); + assert(i == v.begin() + 10); + int j; + for (j = 0; j < 10; ++j) + assert(v[j] == 0); + assert(v[j] == 1); + for (++j; j < 101; ++j) + assert(v[j] == 0); + } +#if _LIBCPP_DEBUG2 >= 1 + { + std::vector> v1(3); + std::vector> v2(3); + int i = 4; + v1.insert(v2.begin(), i); + assert(false); + } +#endif +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp index abfefb0dd855..f31b23398381 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp @@ -18,6 +18,7 @@ #include #include #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" #if _LIBCPP_DEBUG2 >= 1 #include @@ -38,4 +39,17 @@ int main() assert(false); #endif } +#if __cplusplus >= 201103L + { + std::vector> c; + c.push_back(1); + assert(c.size() == 1); + c.pop_back(); + assert(c.size() == 0); +#if _LIBCPP_DEBUG2 >= 1 + c.pop_back(); + assert(false); +#endif + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/push_back.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/push_back.pass.cpp index fba4d0b8a438..3170fe86363c 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/push_back.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/push_back.pass.cpp @@ -14,6 +14,7 @@ #include #include #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -63,4 +64,29 @@ int main() for (int j = 0; j < c.size(); ++j) assert(c[j] == j); } +#if __cplusplus >= 201103L + { + std::vector> c; + c.push_back(0); + assert(c.size() == 1); + for (int j = 0; j < c.size(); ++j) + assert(c[j] == j); + c.push_back(1); + assert(c.size() == 2); + for (int j = 0; j < c.size(); ++j) + assert(c[j] == j); + c.push_back(2); + assert(c.size() == 3); + for (int j = 0; j < c.size(); ++j) + assert(c[j] == j); + c.push_back(3); + assert(c.size() == 4); + for (int j = 0; j < c.size(); ++j) + assert(c[j] == j); + c.push_back(4); + assert(c.size() == 5); + for (int j = 0; j < c.size(); ++j) + assert(c[j] == j); + } +#endif } diff --git a/libcxx/test/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp b/libcxx/test/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp index 1f0bc766e73f..0127dbc65907 100644 --- a/libcxx/test/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../MoveOnly.h" #include "../../../stack_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -65,5 +66,30 @@ int main() for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); } +#if __cplusplus >= 201103L + { + std::vector> c; + c.push_back(MoveOnly(0)); + assert(c.size() == 1); + for (int j = 0; j < c.size(); ++j) + assert(c[j] == MoveOnly(j)); + c.push_back(MoveOnly(1)); + assert(c.size() == 2); + for (int j = 0; j < c.size(); ++j) + assert(c[j] == MoveOnly(j)); + c.push_back(MoveOnly(2)); + assert(c.size() == 3); + for (int j = 0; j < c.size(); ++j) + assert(c[j] == MoveOnly(j)); + c.push_back(MoveOnly(3)); + assert(c.size() == 4); + for (int j = 0; j < c.size(); ++j) + assert(c[j] == MoveOnly(j)); + c.push_back(MoveOnly(4)); + assert(c.size() == 5); + for (int j = 0; j < c.size(); ++j) + assert(c[j] == MoveOnly(j)); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp b/libcxx/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp index e0ae8081e6dc..6454a6940d3c 100644 --- a/libcxx/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { #if _LIBCPP_DEBUG2 >= 1 @@ -35,5 +37,20 @@ int main() c1.erase(i1); assert(false); } +#if __cplusplus >= 201103L + { + int a1[] = {1, 3, 7, 9, 10}; + int a2[] = {0, 2, 4, 5, 6, 8, 11}; + std::vector> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::vector> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + std::vector>::iterator i1 = c1.begin(); + std::vector>::iterator i2 = c2.begin(); + swap(c1, c2); + c1.erase(i2); + c2.erase(i1); + c1.erase(i1); + assert(false); + } +#endif #endif } diff --git a/libcxx/test/containers/sequences/vector/vector.special/swap.pass.cpp b/libcxx/test/containers/sequences/vector/vector.special/swap.pass.cpp index 7cad0f451358..8e2ea3720367 100644 --- a/libcxx/test/containers/sequences/vector/vector.special/swap.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.special/swap.pass.cpp @@ -15,6 +15,7 @@ #include #include #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -85,4 +86,61 @@ int main() assert((c2 == std::vector(a1, a1+sizeof(a1)/sizeof(a1[0])))); assert(c2.get_allocator() == A(1)); } +#if __cplusplus >= 201103L + { + int a1[] = {1, 3, 7, 9, 10}; + int a2[] = {0, 2, 4, 5, 6, 8, 11}; + std::vector> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::vector> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + swap(c1, c2); + assert((c1 == std::vector>(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert((c2 == std::vector>(a1, a1+sizeof(a1)/sizeof(a1[0])))); + } + { + int a1[] = {1, 3, 7, 9, 10}; + int a2[] = {0, 2, 4, 5, 6, 8, 11}; + std::vector> c1(a1, a1); + std::vector> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + swap(c1, c2); + assert((c1 == std::vector>(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert(c2.empty()); + assert(distance(c2.begin(), c2.end()) == 0); + } + { + int a1[] = {1, 3, 7, 9, 10}; + int a2[] = {0, 2, 4, 5, 6, 8, 11}; + std::vector> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::vector> c2(a2, a2); + swap(c1, c2); + assert(c1.empty()); + assert(distance(c1.begin(), c1.end()) == 0); + assert((c2 == std::vector>(a1, a1+sizeof(a1)/sizeof(a1[0])))); + } + { + int a1[] = {1, 3, 7, 9, 10}; + int a2[] = {0, 2, 4, 5, 6, 8, 11}; + std::vector> c1(a1, a1); + std::vector> c2(a2, a2); + swap(c1, c2); + assert(c1.empty()); + assert(distance(c1.begin(), c1.end()) == 0); + assert(c2.empty()); + assert(distance(c2.begin(), c2.end()) == 0); + } +#ifndef _LIBCPP_DEBUG_LEVEL +// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1 + { + int a1[] = {1, 3, 7, 9, 10}; + int a2[] = {0, 2, 4, 5, 6, 8, 11}; + typedef min_allocator A; + std::vector c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A()); + std::vector c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A()); + swap(c1, c2); + assert((c1 == std::vector(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert(c1.get_allocator() == A()); + assert((c2 == std::vector(a1, a1+sizeof(a1)/sizeof(a1[0])))); + assert(c2.get_allocator() == A()); + } +#endif +#endif }