From 81381a932fbebb384adfe5c0116d45b37479efde Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Mon, 24 Jun 2013 17:17:28 +0000 Subject: [PATCH] Implement full support for non-pointer pointers in custom allocators for forward_list. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@184759 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/forward_list | 71 ++++++++-------- .../forwardlist.access/front.pass.cpp | 22 +++++ .../forwardlist.cons/alloc.pass.cpp | 11 +++ .../forwardlist.cons/assign_copy.pass.cpp | 27 +++++++ .../forwardlist.cons/assign_init.pass.cpp | 26 ++++++ .../forwardlist.cons/assign_move.pass.cpp | 37 +++++++++ .../forwardlist.cons/assign_op_init.pass.cpp | 26 ++++++ .../forwardlist.cons/assign_range.pass.cpp | 29 +++++++ .../assign_size_value.pass.cpp | 26 ++++++ .../forwardlist.cons/copy.pass.cpp | 17 ++++ .../forwardlist.cons/copy_alloc.pass.cpp | 17 ++++ .../forwardlist.cons/default.pass.cpp | 10 +++ .../forwardlist.cons/init.pass.cpp | 13 +++ .../forwardlist.cons/init_alloc.pass.cpp | 14 ++++ .../forwardlist.cons/move.pass.cpp | 18 +++++ .../forwardlist.cons/move_alloc.pass.cpp | 18 +++++ .../forwardlist.cons/range.pass.cpp | 14 ++++ .../forwardlist.cons/range_alloc.pass.cpp | 16 ++++ .../forwardlist.cons/size.pass.cpp | 17 ++++ .../forwardlist.cons/size_value.pass.cpp | 15 ++++ .../size_value_alloc.pass.cpp | 16 ++++ .../forwardlist.iter/before_begin.pass.cpp | 43 ++++++++++ .../forwardlist.iter/iterators.pass.cpp | 51 ++++++++++++ .../forwardlist.modifiers/clear.pass.cpp | 22 +++++ .../emplace_after.pass.cpp | 34 ++++++++ .../emplace_front.pass.cpp | 15 ++++ .../erase_after_many.pass.cpp | 70 ++++++++++++++++ .../erase_after_one.pass.cpp | 41 ++++++++++ .../insert_after_const.pass.cpp | 36 +++++++++ .../insert_after_init.pass.cpp | 29 +++++++ .../insert_after_range.pass.cpp | 30 +++++++ .../insert_after_rv.pass.cpp | 35 ++++++++ .../insert_after_size_value.pass.cpp | 29 +++++++ .../forwardlist.modifiers/pop_front.pass.cpp | 30 +++++++ .../push_front_const.pass.cpp | 16 ++++ .../push_front_rv.pass.cpp | 15 ++++ .../resize_size.pass.cpp | 48 +++++++++++ .../resize_size_value.pass.cpp | 33 ++++++++ .../forwardlist.ops/merge.pass.cpp | 16 ++++ .../forwardlist.ops/merge_pred.pass.cpp | 16 ++++ .../forwardlist.ops/remove.pass.cpp | 51 ++++++++++++ .../forwardlist.ops/remove_if.pass.cpp | 51 ++++++++++++ .../forwardlist.ops/reverse.pass.cpp | 13 ++- .../forwardlist/forwardlist.ops/sort.pass.cpp | 14 +++- .../forwardlist.ops/sort_pred.pass.cpp | 14 +++- .../splice_after_flist.pass.cpp | 26 +++++- .../forwardlist.ops/splice_after_one.pass.cpp | 43 +++++++++- .../splice_after_range.pass.cpp | 57 ++++++++++++- .../forwardlist.ops/unique.pass.cpp | 52 ++++++++++++ .../forwardlist.ops/unique_pred.pass.cpp | 52 ++++++++++++ .../forwardlist.spec/equal.pass.cpp | 13 ++- .../forwardlist.spec/member_swap.pass.cpp | 81 +++++++++++++++++++ .../forwardlist.spec/non_member_swap.pass.cpp | 81 +++++++++++++++++++ .../forwardlist.spec/relational.pass.cpp | 13 ++- .../sequences/forwardlist/max_size.pass.cpp | 10 +++ .../sequences/forwardlist/types.pass.cpp | 12 +++ 56 files changed, 1591 insertions(+), 61 deletions(-) diff --git a/include/forward_list b/include/forward_list index 0cbf2fdb..88bf75f9 100644 --- a/include/forward_list +++ b/include/forward_list @@ -232,7 +232,7 @@ public: typedef forward_iterator_tag iterator_category; typedef typename pointer_traits<__node_pointer>::element_type::value_type value_type; - typedef value_type& reference; + typedef value_type& reference; typedef typename pointer_traits<__node_pointer>::difference_type difference_type; typedef typename pointer_traits<__node_pointer>::template @@ -249,7 +249,7 @@ public: _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;} _LIBCPP_INLINE_VISIBILITY - pointer operator->() const {return &__ptr_->__value_;} + pointer operator->() const {return pointer_traits::pointer_to(__ptr_->__value_);} _LIBCPP_INLINE_VISIBILITY __forward_list_iterator& operator++() @@ -303,7 +303,7 @@ class _LIBCPP_TYPE_VIS __forward_list_const_iterator public: typedef forward_iterator_tag iterator_category; typedef typename __node::value_type value_type; - typedef const value_type& reference; + typedef const value_type& reference; typedef typename pointer_traits<__node_const_pointer>::difference_type difference_type; typedef typename pointer_traits<__node_const_pointer>::template @@ -323,7 +323,7 @@ public: _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;} _LIBCPP_INLINE_VISIBILITY - pointer operator->() const {return &__ptr_->__value_;} + pointer operator->() const {return pointer_traits::pointer_to(__ptr_->__value_);} _LIBCPP_INLINE_VISIBILITY __forward_list_const_iterator& operator++() @@ -368,18 +368,27 @@ protected: __node_allocator; typedef allocator_traits<__node_allocator> __node_traits; typedef typename __node_traits::pointer __node_pointer; - typedef typename __node_traits::const_pointer __node_const_pointer; + typedef typename __node_traits::pointer __node_const_pointer; + + typedef typename allocator_traits::template +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + rebind_alloc<__begin_node> +#else + rebind_alloc<__begin_node>::other +#endif + __begin_node_allocator; + typedef typename allocator_traits<__begin_node_allocator>::pointer __begin_node_pointer; __compressed_pair<__begin_node, __node_allocator> __before_begin_; _LIBCPP_INLINE_VISIBILITY __node_pointer __before_begin() _NOEXCEPT - {return pointer_traits<__node_pointer>::pointer_to( - static_cast<__node&>(__before_begin_.first()));} + {return static_cast<__node_pointer>(pointer_traits<__begin_node_pointer>:: + pointer_to(__before_begin_.first()));} _LIBCPP_INLINE_VISIBILITY __node_const_pointer __before_begin() const _NOEXCEPT - {return pointer_traits<__node_const_pointer>::pointer_to( - static_cast(__before_begin_.first()));} + {return static_cast<__node_const_pointer>(pointer_traits<__begin_node_pointer>:: + pointer_to(const_cast<__begin_node&>(__before_begin_.first())));} _LIBCPP_INLINE_VISIBILITY __node_allocator& __alloc() _NOEXCEPT @@ -389,7 +398,7 @@ protected: {return __before_begin_.second();} typedef __forward_list_iterator<__node_pointer> iterator; - typedef __forward_list_const_iterator<__node_const_pointer> const_iterator; + typedef __forward_list_const_iterator<__node_pointer> const_iterator; _LIBCPP_INLINE_VISIBILITY __forward_list_base() @@ -1050,7 +1059,7 @@ template typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::emplace_after(const_iterator __p, _Args&&... __args) { - __node_pointer const __r = const_cast<__node_pointer>(__p.__ptr_); + __node_pointer const __r = __p.__ptr_; __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); @@ -1067,7 +1076,7 @@ template typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) { - __node_pointer const __r = const_cast<__node_pointer>(__p.__ptr_); + __node_pointer const __r = __p.__ptr_; __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); @@ -1083,7 +1092,7 @@ template typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, const value_type& __v) { - __node_pointer const __r = const_cast<__node_pointer>(__p.__ptr_); + __node_pointer const __r = __p.__ptr_; __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); @@ -1098,7 +1107,7 @@ typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const value_type& __v) { - __node_pointer __r = const_cast<__node_pointer>(__p.__ptr_); + __node_pointer __r = __p.__ptr_; if (__n > 0) { __node_allocator& __a = base::__alloc(); @@ -1148,7 +1157,7 @@ typename enable_if forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l) { - __node_pointer __r = const_cast<__node_pointer>(__p.__ptr_); + __node_pointer __r = __p.__ptr_; if (__f != __l) { __node_allocator& __a = base::__alloc(); @@ -1192,7 +1201,7 @@ template typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::erase_after(const_iterator __f) { - __node_pointer __p = const_cast<__node_pointer>(__f.__ptr_); + __node_pointer __p = __f.__ptr_; __node_pointer __n = __p->__next_; __p->__next_ = __n->__next_; __node_allocator& __a = base::__alloc(); @@ -1205,10 +1214,10 @@ template typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l) { - __node_pointer __e = const_cast<__node_pointer>(__l.__ptr_); + __node_pointer __e = __l.__ptr_; if (__f != __l) { - __node_pointer __p = const_cast<__node_pointer>(__f.__ptr_); + __node_pointer __p = __f.__ptr_; __node_pointer __n = __p->__next_; if (__n != __e) { @@ -1302,12 +1311,10 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, const_iterator __lm1 = __x.before_begin(); while (__lm1.__ptr_->__next_ != nullptr) ++__lm1; - const_cast<__node_pointer>(__lm1.__ptr_)->__next_ = - const_cast<__node_pointer>(__p.__ptr_)->__next_; + __lm1.__ptr_->__next_ = __p.__ptr_->__next_; } - const_cast<__node_pointer>(__p.__ptr_)->__next_ = - const_cast<__node_pointer>(__x.__before_begin())->__next_; - const_cast<__node_pointer>(__x.__before_begin())->__next_ = nullptr; + __p.__ptr_->__next_ = __x.__before_begin()->__next_; + __x.__before_begin()->__next_ = nullptr; } } @@ -1320,12 +1327,9 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, const_iterator __lm1 = _VSTD::next(__i); if (__p != __i && __p != __lm1) { - const_cast<__node_pointer>(__i.__ptr_)->__next_ = - const_cast<__node_pointer>(__lm1.__ptr_)->__next_; - const_cast<__node_pointer>(__lm1.__ptr_)->__next_ = - const_cast<__node_pointer>(__p.__ptr_)->__next_; - const_cast<__node_pointer>(__p.__ptr_)->__next_ = - const_cast<__node_pointer>(__lm1.__ptr_); + __i.__ptr_->__next_ = __lm1.__ptr_->__next_; + __lm1.__ptr_->__next_ = __p.__ptr_->__next_; + __p.__ptr_->__next_ = __lm1.__ptr_; } } @@ -1342,12 +1346,9 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, ++__lm1; if (__f != __lm1) { - const_cast<__node_pointer>(__lm1.__ptr_)->__next_ = - const_cast<__node_pointer>(__p.__ptr_)->__next_; - const_cast<__node_pointer>(__p.__ptr_)->__next_ = - const_cast<__node_pointer>(__f.__ptr_)->__next_; - const_cast<__node_pointer>(__f.__ptr_)->__next_ = - const_cast<__node_pointer>(__l.__ptr_); + __lm1.__ptr_->__next_ = __p.__ptr_->__next_; + __p.__ptr_->__next_ = __f.__ptr_->__next_; + __f.__ptr_->__next_ = __l.__ptr_; } } } diff --git a/test/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp index 5f9d701d..9a201aaf 100644 --- a/test/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -36,4 +38,24 @@ int main() assert(c.front() == 0); assert(*c.begin() == 0); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + C c(std::begin(t), std::end(t)); + assert(c.front() == 0); + c.front() = 10; + assert(c.front() == 10); + assert(*c.begin() == 10); + } + { + typedef int T; + typedef std::forward_list> C; + const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + const C c(std::begin(t), std::end(t)); + assert(c.front() == 0); + assert(*c.begin() == 0); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp index 380d3c10..31832875 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp @@ -16,6 +16,7 @@ #include "../../../test_allocator.h" #include "../../../NotConstructible.h" +#include "../../../min_allocator.h" int main() { @@ -27,4 +28,14 @@ int main() assert(c.get_allocator() == A(12)); assert(c.empty()); } +#if __cplusplus >= 201103L + { + typedef min_allocator A; + typedef A::value_type T; + typedef std::forward_list C; + C c(A{}); + assert(c.get_allocator() == A()); + assert(c.empty()); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp index 82e14546..0379e47f 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp @@ -16,6 +16,7 @@ #include #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -116,4 +117,30 @@ int main() assert(c1 == c0); assert(c1.get_allocator() == A(10)); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef min_allocator A; + typedef std::forward_list C; + const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + const T t1[] = {10, 11, 12, 13}; + C c0(std::begin(t0), std::end(t0), A()); + C c1(std::begin(t1), std::end(t1), A()); + c1 = c0; + assert(c1 == c0); + assert(c1.get_allocator() == A()); + } + { + typedef int T; + typedef min_allocator A; + typedef std::forward_list C; + const T t0[] = {10, 11, 12, 13}; + const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + C c0(std::begin(t0), std::end(t0), A()); + C c1(std::begin(t1), std::end(t1), A()); + c1 = c0; + assert(c1 == c0); + assert(c1.get_allocator() == A()); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp index d79c5032..088ed6d9 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -40,5 +42,29 @@ int main() assert(*i == 10+n); assert(n == 4); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {10, 11, 12, 13}; + C c(std::begin(t1), std::end(t1)); + c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + int n = 0; + for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n) + assert(*i == n); + assert(n == 10); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + C c(std::begin(t1), std::end(t1)); + c.assign({10, 11, 12, 13}); + int n = 0; + for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n) + assert(*i == 10+n); + assert(n == 4); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp index 5ac81eed..480350be 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp @@ -17,6 +17,7 @@ #include "../../../test_allocator.h" #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -158,5 +159,41 @@ int main() assert(c1.get_allocator() == A(10)); assert(c0.empty()); } +#if __cplusplus >= 201103L + { + typedef MoveOnly T; + typedef min_allocator A; + typedef std::forward_list C; + T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + T t1[] = {10, 11, 12, 13}; + typedef std::move_iterator I; + C c0(I(std::begin(t0)), I(std::end(t0)), A()); + C c1(I(std::begin(t1)), I(std::end(t1)), A()); + c1 = std::move(c0); + int n = 0; + for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n) + assert(*i == n); + assert(n == 10); + assert(c1.get_allocator() == A()); + assert(c0.empty()); + } + { + typedef MoveOnly T; + typedef min_allocator A; + typedef std::forward_list C; + T t0[] = {10, 11, 12, 13}; + T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + typedef std::move_iterator I; + C c0(I(std::begin(t0)), I(std::end(t0)), A()); + C c1(I(std::begin(t1)), I(std::end(t1)), A()); + c1 = std::move(c0); + int n = 0; + for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n) + assert(*i == 10+n); + assert(n == 4); + assert(c1.get_allocator() == A()); + assert(c0.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp index b880bc2b..5efe79ff 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -40,5 +42,29 @@ int main() assert(*i == 10+n); assert(n == 4); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {10, 11, 12, 13}; + C c(std::begin(t1), std::end(t1)); + c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + int n = 0; + for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n) + assert(*i == n); + assert(n == 10); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + C c(std::begin(t1), std::end(t1)); + c = {10, 11, 12, 13}; + int n = 0; + for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n) + assert(*i == 10+n); + assert(n == 4); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp index 38fef428..ccbd7ce5 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp @@ -17,6 +17,7 @@ #include #include "test_iterators.h" +#include "../../../min_allocator.h" int main() { @@ -46,4 +47,32 @@ int main() assert(*i == 10+n); assert(n == 4); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + const T t1[] = {10, 11, 12, 13}; + C c(std::begin(t1), std::end(t1)); + typedef input_iterator I; + c.assign(I(std::begin(t0)), I(std::end(t0))); + int n = 0; + for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n) + assert(*i == n); + assert(n == 10); + } + { + typedef int T; + typedef std::forward_list> C; + const T t0[] = {10, 11, 12, 13}; + const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + C c(std::begin(t1), std::end(t1)); + typedef input_iterator I; + c.assign(I(std::begin(t0)), I(std::end(t0))); + int n = 0; + for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n) + assert(*i == 10+n); + assert(n == 4); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp index 53add157..7e7dbb63 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -39,4 +41,28 @@ int main() assert(*i == 10); assert(n == 4); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {10, 11, 12, 13}; + C c(std::begin(t1), std::end(t1)); + c.assign(10, 1); + int n = 0; + for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n) + assert(*i == 1); + assert(n == 10); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + C c(std::begin(t1), std::end(t1)); + c.assign(4, 10); + int n = 0; + for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n) + assert(*i == 10); + assert(n == 4); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp index 7bd2668a..0c3f1623 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp @@ -16,6 +16,7 @@ #include #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -49,4 +50,20 @@ int main() assert(c.get_allocator() == A(-2)); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if __cplusplus >= 201103L + { + typedef int T; + typedef min_allocator A; + typedef std::forward_list C; + const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + C c0(std::begin(t), std::end(t), A()); + C c = c0; + unsigned n = 0; + for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) + assert(*i == n); + assert(n == std::end(t) - std::begin(t)); + assert(c == c0); + assert(c.get_allocator() == A()); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp index e085f651..76496793 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp @@ -16,6 +16,7 @@ #include #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -47,4 +48,20 @@ int main() assert(c == c0); assert(c.get_allocator() == A(9)); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef min_allocator A; + typedef std::forward_list C; + const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + C c0(std::begin(t), std::end(t), A()); + C c(c0, A()); + unsigned n = 0; + for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) + assert(*i == n); + assert(n == std::end(t) - std::begin(t)); + assert(c == c0); + assert(c.get_allocator() == A()); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp index 7c6c357c..aa002360 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -22,4 +24,12 @@ int main() C c; assert(c.empty()); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + C c; + assert(c.empty()); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp index 503e97bc..987185dc 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -26,5 +28,16 @@ int main() assert(*i == n); assert(n == 10); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + unsigned n = 0; + for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) + assert(*i == n); + assert(n == 10); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp index cd36b44b..4b62a42e 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -30,5 +31,18 @@ int main() assert(n == 10); assert(c.get_allocator() == A(14)); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef min_allocator A; + typedef std::forward_list C; + C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A()); + unsigned n = 0; + for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) + assert(*i == n); + assert(n == 10); + assert(c.get_allocator() == A()); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp index a5b47254..01b12597 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp @@ -17,6 +17,7 @@ #include "../../../test_allocator.h" #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -51,5 +52,22 @@ int main() assert(c0.empty()); assert(c.get_allocator() == A(10)); } +#if __cplusplus >= 201103L + { + typedef MoveOnly T; + typedef min_allocator A; + typedef std::forward_list C; + T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + typedef std::move_iterator I; + C c0(I(std::begin(t)), I(std::end(t)), A()); + C c = std::move(c0); + unsigned n = 0; + for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) + assert(*i == n); + assert(n == std::end(t) - std::begin(t)); + assert(c0.empty()); + assert(c.get_allocator() == A()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp index 47f95921..b659e88e 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp @@ -17,6 +17,7 @@ #include "../../../test_allocator.h" #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -51,5 +52,22 @@ int main() assert(!c0.empty()); assert(c.get_allocator() == A(9)); } +#if __cplusplus >= 201103L + { + typedef MoveOnly T; + typedef min_allocator A; + typedef std::forward_list C; + T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + typedef std::move_iterator I; + C c0(I(std::begin(t)), I(std::end(t)), A()); + C c(std::move(c0), A()); + unsigned n = 0; + for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) + assert(*i == n); + assert(n == std::end(t) - std::begin(t)); + assert(c0.empty()); + assert(c.get_allocator() == A()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp index e9c8aba9..57d34506 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp @@ -17,6 +17,7 @@ #include #include "test_iterators.h" +#include "../../../min_allocator.h" int main() { @@ -31,4 +32,17 @@ int main() assert(*i == n); assert(n == std::end(t) - std::begin(t)); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + typedef input_iterator I; + const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + C c(I(std::begin(t)), I(std::end(t))); + unsigned n = 0; + for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) + assert(*i == n); + assert(n == std::end(t) - std::begin(t)); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp index 0eec764f..8f3b39a6 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp @@ -19,6 +19,7 @@ #include "../../../test_allocator.h" #include "test_iterators.h" +#include "../../../min_allocator.h" int main() { @@ -35,4 +36,19 @@ int main() assert(n == std::end(t) - std::begin(t)); assert(c.get_allocator() == A(13)); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef min_allocator A; + typedef std::forward_list C; + typedef input_iterator I; + const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + C c(I(std::begin(t)), I(std::end(t)), A()); + unsigned n = 0; + for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) + assert(*i == n); + assert(n == std::end(t) - std::begin(t)); + assert(c.get_allocator() == A()); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp index eeffb70b..1a993681 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../DefaultOnly.h" +#include "../../../min_allocator.h" int main() { @@ -32,4 +33,20 @@ int main() #endif assert(n == N); } +#if __cplusplus >= 201103L + { + typedef DefaultOnly T; + typedef std::forward_list> C; + unsigned N = 10; + C c(N); + unsigned n = 0; + for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + assert(*i == T()); +#else + ; +#endif + assert(n == N); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp index f95e7838..4981d7e4 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -27,4 +29,17 @@ int main() assert(*i == v); assert(n == N); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + T v(6); + unsigned N = 10; + C c(N, v); + unsigned n = 0; + for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) + assert(*i == v); + assert(n == N); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp index 34835d63..da4e80da 100644 --- a/test/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -31,4 +32,19 @@ int main() assert(n == N); assert(c.get_allocator() == A(12)); } +#if __cplusplus >= 201103L + { + typedef min_allocator A; + typedef A::value_type T; + typedef std::forward_list C; + T v(6); + unsigned N = 10; + C c(N, v, A()); + unsigned n = 0; + for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) + assert(*i == v); + assert(n == N); + assert(c.get_allocator() == A()); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp index 947d0dc3..1b891772 100644 --- a/test/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp @@ -17,6 +17,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -58,4 +60,45 @@ int main() C::const_iterator i = c.before_begin(); assert(std::distance(i, c.end()) == 11); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + C c; + C::iterator i = c.before_begin(); + assert(std::distance(i, c.end()) == 1); + } + { + typedef int T; + typedef std::forward_list> C; + const C c; + C::const_iterator i = c.before_begin(); + assert(std::distance(i, c.end()) == 1); + } + { + typedef int T; + typedef std::forward_list> C; + const C c; + C::const_iterator i = c.cbefore_begin(); + assert(std::distance(i, c.end()) == 1); + assert(c.cbefore_begin() == c.before_begin()); + } + { + typedef int T; + typedef std::forward_list> 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.before_begin(); + assert(std::distance(i, c.end()) == 11); + assert(std::next(c.before_begin()) == c.begin()); + } + { + typedef int T; + typedef std::forward_list> C; + const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + const C c(std::begin(t), std::end(t)); + C::const_iterator i = c.before_begin(); + assert(std::distance(i, c.end()) == 11); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp index e27e34bc..c03c3114 100644 --- a/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp @@ -20,6 +20,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -69,4 +71,53 @@ int main() C::iterator i; C::const_iterator j; } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> 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::forward_list> 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::forward_list> 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::forward_list> 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::forward_list> C; + C::iterator i; + C::const_iterator j; + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp index 5c9c7bb2..33db9e9e 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../NotConstructible.h" +#include "../../../min_allocator.h" int main() { @@ -37,4 +38,25 @@ int main() c.clear(); assert(distance(c.begin(), c.end()) == 0); } +#if __cplusplus >= 201103L + { + typedef NotConstructible T; + typedef std::forward_list> C; + C c; + c.clear(); + assert(distance(c.begin(), c.end()) == 0); + } + { + typedef int T; + typedef std::forward_list> C; + const T t[] = {0, 1, 2, 3, 4}; + C c(std::begin(t), std::end(t)); + + c.clear(); + assert(distance(c.begin(), c.end()) == 0); + + c.clear(); + assert(distance(c.begin(), c.end()) == 0); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp index db18c912..680b5b84 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp @@ -16,6 +16,7 @@ #include #include "../../../Emplaceable.h" +#include "../../../min_allocator.h" int main() { @@ -51,5 +52,38 @@ int main() assert(*next(c.begin(), 3) == Emplaceable(2, 3.5)); assert(distance(c.begin(), c.end()) == 4); } +#if __cplusplus >= 201103L + { + typedef Emplaceable T; + typedef std::forward_list> C; + typedef C::iterator I; + C c; + I i = c.emplace_after(c.cbefore_begin()); + assert(i == c.begin()); + assert(c.front() == Emplaceable()); + assert(distance(c.begin(), c.end()) == 1); + + i = c.emplace_after(c.cbegin(), 1, 2.5); + assert(i == next(c.begin())); + assert(c.front() == Emplaceable()); + assert(*next(c.begin()) == Emplaceable(1, 2.5)); + assert(distance(c.begin(), c.end()) == 2); + + i = c.emplace_after(next(c.cbegin()), 2, 3.5); + assert(i == next(c.begin(), 2)); + assert(c.front() == Emplaceable()); + assert(*next(c.begin()) == Emplaceable(1, 2.5)); + assert(*next(c.begin(), 2) == Emplaceable(2, 3.5)); + assert(distance(c.begin(), c.end()) == 3); + + i = c.emplace_after(c.cbegin(), 3, 4.5); + assert(i == next(c.begin())); + assert(c.front() == Emplaceable()); + assert(*next(c.begin(), 1) == Emplaceable(3, 4.5)); + assert(*next(c.begin(), 2) == Emplaceable(1, 2.5)); + assert(*next(c.begin(), 3) == Emplaceable(2, 3.5)); + assert(distance(c.begin(), c.end()) == 4); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp index 27b67e52..f3c7f4aa 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../Emplaceable.h" +#include "../../../min_allocator.h" int main() { @@ -31,5 +32,19 @@ int main() assert(*next(c.begin()) == Emplaceable()); assert(distance(c.begin(), c.end()) == 2); } +#if __cplusplus >= 201103L + { + typedef Emplaceable T; + typedef std::forward_list> C; + C c; + c.emplace_front(); + assert(c.front() == Emplaceable()); + assert(distance(c.begin(), c.end()) == 1); + c.emplace_front(1, 2.5); + assert(c.front() == Emplaceable(1, 2.5)); + assert(*next(c.begin()) == Emplaceable()); + assert(distance(c.begin(), c.end()) == 2); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp index 2e5f68f2..f3265930 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -82,4 +84,72 @@ int main() assert(i == c.end()); assert(distance(c.begin(), c.end()) == 0); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> 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.erase_after(next(c.cbefore_begin(), 4), next(c.cbefore_begin(), 4)); + assert(i == next(c.cbefore_begin(), 4)); + assert(distance(c.begin(), c.end()) == 10); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 1); + assert(*next(c.begin(), 2) == 2); + assert(*next(c.begin(), 3) == 3); + assert(*next(c.begin(), 4) == 4); + assert(*next(c.begin(), 5) == 5); + assert(*next(c.begin(), 6) == 6); + assert(*next(c.begin(), 7) == 7); + assert(*next(c.begin(), 8) == 8); + assert(*next(c.begin(), 9) == 9); + + i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 5)); + assert(i == next(c.begin(), 2)); + assert(distance(c.begin(), c.end()) == 8); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 1); + assert(*next(c.begin(), 2) == 4); + assert(*next(c.begin(), 3) == 5); + assert(*next(c.begin(), 4) == 6); + assert(*next(c.begin(), 5) == 7); + assert(*next(c.begin(), 6) == 8); + assert(*next(c.begin(), 7) == 9); + + i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 3)); + assert(i == next(c.begin(), 2)); + assert(distance(c.begin(), c.end()) == 8); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 1); + assert(*next(c.begin(), 2) == 4); + assert(*next(c.begin(), 3) == 5); + assert(*next(c.begin(), 4) == 6); + assert(*next(c.begin(), 5) == 7); + assert(*next(c.begin(), 6) == 8); + assert(*next(c.begin(), 7) == 9); + + i = c.erase_after(next(c.cbefore_begin(), 5), next(c.cbefore_begin(), 9)); + assert(i == c.end()); + assert(distance(c.begin(), c.end()) == 5); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 1); + assert(*next(c.begin(), 2) == 4); + assert(*next(c.begin(), 3) == 5); + assert(*next(c.begin(), 4) == 6); + + i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 2)); + assert(i == c.begin()); + assert(distance(c.begin(), c.end()) == 4); + assert(*next(c.begin(), 0) == 1); + assert(*next(c.begin(), 1) == 4); + assert(*next(c.begin(), 2) == 5); + assert(*next(c.begin(), 3) == 6); + + i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 5)); + assert(i == c.begin()); + assert(i == c.end()); + assert(distance(c.begin(), c.end()) == 0); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp index 6b706ded..e36089e3 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -53,4 +55,43 @@ int main() assert(i == c.end()); assert(distance(c.begin(), c.end()) == 0); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + const T t[] = {0, 1, 2, 3, 4}; + C c(std::begin(t), std::end(t)); + + C::iterator i = c.erase_after(next(c.cbefore_begin(), 4)); + assert(i == c.end()); + assert(distance(c.begin(), c.end()) == 4); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 1); + assert(*next(c.begin(), 2) == 2); + assert(*next(c.begin(), 3) == 3); + + i = c.erase_after(next(c.cbefore_begin(), 0)); + assert(i == c.begin()); + assert(distance(c.begin(), c.end()) == 3); + assert(*next(c.begin(), 0) == 1); + assert(*next(c.begin(), 1) == 2); + assert(*next(c.begin(), 2) == 3); + + i = c.erase_after(next(c.cbefore_begin(), 1)); + assert(i == next(c.begin())); + assert(distance(c.begin(), c.end()) == 2); + assert(*next(c.begin(), 0) == 1); + assert(*next(c.begin(), 1) == 3); + + i = c.erase_after(next(c.cbefore_begin(), 1)); + assert(i == c.end()); + assert(distance(c.begin(), c.end()) == 1); + assert(*next(c.begin(), 0) == 1); + + i = c.erase_after(next(c.cbefore_begin(), 0)); + assert(i == c.begin()); + assert(i == c.end()); + assert(distance(c.begin(), c.end()) == 0); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp index 5cfb8ade..b6785e72 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -48,4 +50,38 @@ int main() assert(*next(c.begin(), 3) == 2); assert(distance(c.begin(), c.end()) == 4); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + typedef C::iterator I; + C c; + I i = c.insert_after(c.cbefore_begin(), 0); + assert(i == c.begin()); + assert(c.front() == 0); + assert(c.front() == 0); + assert(distance(c.begin(), c.end()) == 1); + + i = c.insert_after(c.cbegin(), 1); + assert(i == next(c.begin())); + assert(c.front() == 0); + assert(*next(c.begin()) == 1); + assert(distance(c.begin(), c.end()) == 2); + + i = c.insert_after(next(c.cbegin()), 2); + assert(i == next(c.begin(), 2)); + assert(c.front() == 0); + assert(*next(c.begin()) == 1); + assert(*next(c.begin(), 2) == 2); + assert(distance(c.begin(), c.end()) == 3); + + i = c.insert_after(c.cbegin(), 3); + assert(i == next(c.begin())); + assert(c.front() == 0); + assert(*next(c.begin(), 1) == 3); + assert(*next(c.begin(), 2) == 1); + assert(*next(c.begin(), 3) == 2); + assert(distance(c.begin(), c.end()) == 4); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp index eb8b8e1f..7afaacdb 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -42,5 +44,32 @@ int main() assert(*next(c.begin(), 3) == 1); assert(*next(c.begin(), 4) == 2); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + typedef C::iterator I; + C c; + I i = c.insert_after(c.cbefore_begin(), {}); + assert(i == c.before_begin()); + assert(distance(c.begin(), c.end()) == 0); + + i = c.insert_after(c.cbefore_begin(), {0, 1, 2}); + assert(i == next(c.before_begin(), 3)); + assert(distance(c.begin(), c.end()) == 3); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 1); + assert(*next(c.begin(), 2) == 2); + + i = c.insert_after(c.begin(), {3, 4}); + assert(i == next(c.begin(), 2)); + assert(distance(c.begin(), c.end()) == 5); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 3); + assert(*next(c.begin(), 2) == 4); + assert(*next(c.begin(), 3) == 1); + assert(*next(c.begin(), 4) == 2); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp index 4d8ccc2e..dde6a13d 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp @@ -17,6 +17,7 @@ #include #include "test_iterators.h" +#include "../../../min_allocator.h" int main() { @@ -47,4 +48,33 @@ int main() assert(*next(c.begin(), 3) == 1); assert(*next(c.begin(), 4) == 2); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + typedef C::iterator I; + typedef input_iterator J; + C c; + const T t[] = {0, 1, 2, 3, 4}; + I i = c.insert_after(c.cbefore_begin(), J(t), J(t)); + assert(i == c.before_begin()); + assert(distance(c.begin(), c.end()) == 0); + + i = c.insert_after(c.cbefore_begin(), J(t), J(t+3)); + assert(i == next(c.before_begin(), 3)); + assert(distance(c.begin(), c.end()) == 3); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 1); + assert(*next(c.begin(), 2) == 2); + + i = c.insert_after(c.begin(), J(t+3), J(t+5)); + assert(i == next(c.begin(), 2)); + assert(distance(c.begin(), c.end()) == 5); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 3); + assert(*next(c.begin(), 2) == 4); + assert(*next(c.begin(), 3) == 1); + assert(*next(c.begin(), 4) == 2); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp index 44dbe7c8..59f67701 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -51,5 +52,39 @@ int main() assert(*next(c.begin(), 3) == 2); assert(distance(c.begin(), c.end()) == 4); } +#if __cplusplus >= 201103L + { + typedef MoveOnly T; + typedef std::forward_list> C; + typedef C::iterator I; + C c; + I i = c.insert_after(c.cbefore_begin(), 0); + assert(i == c.begin()); + assert(c.front() == 0); + assert(c.front() == 0); + assert(distance(c.begin(), c.end()) == 1); + + i = c.insert_after(c.cbegin(), 1); + assert(i == next(c.begin())); + assert(c.front() == 0); + assert(*next(c.begin()) == 1); + assert(distance(c.begin(), c.end()) == 2); + + i = c.insert_after(next(c.cbegin()), 2); + assert(i == next(c.begin(), 2)); + assert(c.front() == 0); + assert(*next(c.begin()) == 1); + assert(*next(c.begin(), 2) == 2); + assert(distance(c.begin(), c.end()) == 3); + + i = c.insert_after(c.cbegin(), 3); + assert(i == next(c.begin())); + assert(c.front() == 0); + assert(*next(c.begin(), 1) == 3); + assert(*next(c.begin(), 2) == 1); + assert(*next(c.begin(), 3) == 2); + assert(distance(c.begin(), c.end()) == 4); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp index 2bf8b125..42977535 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -41,4 +43,31 @@ int main() assert(*next(c.begin(), 3) == 3); assert(*next(c.begin(), 4) == 3); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + typedef C::iterator I; + C c; + I i = c.insert_after(c.cbefore_begin(), 0, 0); + assert(i == c.before_begin()); + assert(distance(c.begin(), c.end()) == 0); + + i = c.insert_after(c.cbefore_begin(), 3, 3); + assert(i == next(c.before_begin(), 3)); + assert(distance(c.begin(), c.end()) == 3); + assert(*next(c.begin(), 0) == 3); + assert(*next(c.begin(), 1) == 3); + assert(*next(c.begin(), 2) == 3); + + i = c.insert_after(c.begin(), 2, 2); + assert(i == next(c.begin(), 2)); + assert(distance(c.begin(), c.end()) == 5); + assert(*next(c.begin(), 0) == 3); + assert(*next(c.begin(), 1) == 2); + assert(*next(c.begin(), 2) == 2); + assert(*next(c.begin(), 3) == 3); + assert(*next(c.begin(), 4) == 3); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp index c73f6a55..0b73c7a0 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -45,4 +46,33 @@ int main() assert(distance(c.begin(), c.end()) == 0); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + typedef std::forward_list> C; + C c; + c.push_front(1); + c.push_front(3); + c.pop_front(); + assert(distance(c.begin(), c.end()) == 1); + assert(c.front() == 1); + c.pop_front(); + assert(distance(c.begin(), c.end()) == 0); + } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef MoveOnly T; + typedef std::forward_list> C; + C c; + c.push_front(1); + c.push_front(3); + c.pop_front(); + assert(distance(c.begin(), c.end()) == 1); + assert(c.front() == 1); + c.pop_front(); + assert(distance(c.begin(), c.end()) == 0); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp index dd12833a..bcf2865f 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -28,4 +30,18 @@ int main() assert(*next(c.begin()) == 1); assert(distance(c.begin(), c.end()) == 2); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + C c; + c.push_front(1); + assert(c.front() == 1); + assert(distance(c.begin(), c.end()) == 1); + c.push_front(3); + assert(c.front() == 3); + assert(*next(c.begin()) == 1); + assert(distance(c.begin(), c.end()) == 2); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp index ff68826a..f2e99e1e 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../MoveOnly.h" +#include "../../../min_allocator.h" int main() { @@ -31,5 +32,19 @@ int main() assert(*next(c.begin()) == 1); assert(distance(c.begin(), c.end()) == 2); } +#if __cplusplus >= 201103L + { + typedef MoveOnly T; + typedef std::forward_list> C; + C c; + c.push_front(1); + assert(c.front() == 1); + assert(distance(c.begin(), c.end()) == 1); + c.push_front(3); + assert(c.front() == 3); + assert(*next(c.begin()) == 1); + assert(distance(c.begin(), c.end()) == 2); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp index b283b86b..e9372808 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../DefaultOnly.h" +#include "../../../min_allocator.h" int main() { @@ -63,4 +64,51 @@ int main() assert(*next(c.begin(), 4) == 0); assert(*next(c.begin(), 5) == 0); } +#if __cplusplus >= 201103L + { + typedef DefaultOnly T; + typedef std::forward_list> C; + C c; + c.resize(0); + assert(distance(c.begin(), c.end()) == 0); + c.resize(10); + assert(distance(c.begin(), c.end()) == 10); + c.resize(20); + assert(distance(c.begin(), c.end()) == 20); + c.resize(5); + assert(distance(c.begin(), c.end()) == 5); + c.resize(0); + assert(distance(c.begin(), c.end()) == 0); + } + { + typedef int T; + typedef std::forward_list> C; + const T t[] = {0, 1, 2, 3, 4}; + C c(std::begin(t), std::end(t)); + + c.resize(3); + assert(distance(c.begin(), c.end()) == 3); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 1); + assert(*next(c.begin(), 2) == 2); + + c.resize(6); + assert(distance(c.begin(), c.end()) == 6); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 1); + assert(*next(c.begin(), 2) == 2); + assert(*next(c.begin(), 3) == 0); + assert(*next(c.begin(), 4) == 0); + assert(*next(c.begin(), 5) == 0); + + c.resize(6); + assert(distance(c.begin(), c.end()) == 6); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 1); + assert(*next(c.begin(), 2) == 2); + assert(*next(c.begin(), 3) == 0); + assert(*next(c.begin(), 4) == 0); + assert(*next(c.begin(), 5) == 0); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp index 14873aec..89775d15 100644 --- a/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../DefaultOnly.h" +#include "../../../min_allocator.h" int main() { @@ -48,4 +49,36 @@ int main() assert(*next(c.begin(), 4) == 10); assert(*next(c.begin(), 5) == 10); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + const T t[] = {0, 1, 2, 3, 4}; + C c(std::begin(t), std::end(t)); + + c.resize(3, 10); + assert(distance(c.begin(), c.end()) == 3); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 1); + assert(*next(c.begin(), 2) == 2); + + c.resize(6, 10); + assert(distance(c.begin(), c.end()) == 6); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 1); + assert(*next(c.begin(), 2) == 2); + assert(*next(c.begin(), 3) == 10); + assert(*next(c.begin(), 4) == 10); + assert(*next(c.begin(), 5) == 10); + + c.resize(6, 12); + assert(distance(c.begin(), c.end()) == 6); + assert(*next(c.begin(), 0) == 0); + assert(*next(c.begin(), 1) == 1); + assert(*next(c.begin(), 2) == 2); + assert(*next(c.begin(), 3) == 10); + assert(*next(c.begin(), 4) == 10); + assert(*next(c.begin(), 5) == 10); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp index 3e74d801..280d92ca 100644 --- a/test/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -29,4 +31,18 @@ int main() C c3(std::begin(t3), std::end(t3)); assert(c1 == c3); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {3, 5, 6, 7, 12, 13}; + const T t2[] = {0, 1, 2, 4, 8, 9, 10, 11, 14, 15}; + const T t3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.merge(c2); + C c3(std::begin(t3), std::end(t3)); + assert(c1 == c3); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp index fe0a470a..6d6c40ef 100644 --- a/test/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp @@ -16,6 +16,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -30,4 +32,18 @@ int main() C c3(std::begin(t3), std::end(t3)); assert(c1 == c3); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {13, 12, 7, 6, 5, 3}; + const T t2[] = {15, 14, 11, 10, 9, 8, 4, 2, 1, 0}; + const T t3[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.merge(c2, std::greater()); + C c3(std::begin(t3), std::end(t3)); + assert(c1 == c3); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp index 806b6091..98748033 100644 --- a/test/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -64,4 +66,53 @@ int main() c1.remove(0); assert(c1 == c2); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {0, 5, 5, 0, 0, 0, 5}; + const T t2[] = {5, 5, 5}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.remove(0); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {0, 0, 0, 0}; + C c1(std::begin(t1), std::end(t1)); + C c2; + c1.remove(0); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {5, 5, 5}; + const T t2[] = {5, 5, 5}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.remove(0); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + C c1; + C c2; + c1.remove(0); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {5, 5, 5, 0}; + const T t2[] = {5, 5, 5}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.remove(0); + assert(c1 == c2); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp index a8d3b159..93b8ad80 100644 --- a/test/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../../min_allocator.h" + bool g(int i) { return i < 3; @@ -69,4 +71,53 @@ int main() c1.remove_if(g); assert(c1 == c2); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {0, 5, 5, 0, 0, 0, 5}; + const T t2[] = {5, 5, 5}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.remove_if(g); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {0, 0, 0, 0}; + C c1(std::begin(t1), std::end(t1)); + C c2; + c1.remove_if(g); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {5, 5, 5}; + const T t2[] = {5, 5, 5}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.remove_if(g); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + C c1; + C c2; + c1.remove_if(g); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {5, 5, 5, 0}; + const T t2[] = {5, 5, 5}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.remove_if(g); + assert(c1 == c2); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp index 1a1e4449..b707c191 100644 --- a/test/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp @@ -16,16 +16,17 @@ #include #include +#include "../../../min_allocator.h" + +template void test(int N) { - typedef int T; - typedef std::forward_list C; C c; for (int i = 0; i < N; ++i) c.push_front(i); c.reverse(); assert(distance(c.begin(), c.end()) == N); - C::const_iterator j = c.begin(); + typename C::const_iterator j = c.begin(); for (int i = 0; i < N; ++i, ++j) assert(*j == i); } @@ -33,5 +34,9 @@ void test(int N) int main() { for (int i = 0; i < 10; ++i) - test(i); + test >(i); +#if __cplusplus >= 201103L + for (int i = 0; i < 10; ++i) + test> >(i); +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp index 6badaf79..9a8bd17d 100644 --- a/test/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp @@ -17,10 +17,12 @@ #include #include +#include "../../../min_allocator.h" + +template void test(int N) { - typedef int T; - typedef std::forward_list C; + typedef typename C::value_type T; typedef std::vector V; V v; for (int i = 0; i < N; ++i) @@ -29,7 +31,7 @@ void test(int N) C c(v.begin(), v.end()); c.sort(); assert(distance(c.begin(), c.end()) == N); - C::const_iterator j = c.begin(); + typename C::const_iterator j = c.begin(); for (int i = 0; i < N; ++i, ++j) assert(*j == i); } @@ -37,5 +39,9 @@ void test(int N) int main() { for (int i = 0; i < 40; ++i) - test(i); + test >(i); +#if __cplusplus >= 201103L + for (int i = 0; i < 40; ++i) + test> >(i); +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp index dbc58f3c..8524439d 100644 --- a/test/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp @@ -18,10 +18,12 @@ #include #include +#include "../../../min_allocator.h" + +template void test(int N) { - typedef int T; - typedef std::forward_list C; + typedef typename C::value_type T; typedef std::vector V; V v; for (int i = 0; i < N; ++i) @@ -30,7 +32,7 @@ void test(int N) C c(v.begin(), v.end()); c.sort(std::greater()); assert(distance(c.begin(), c.end()) == N); - C::const_iterator j = c.begin(); + typename C::const_iterator j = c.begin(); for (int i = 0; i < N; ++i, ++j) assert(*j == N-1-i); } @@ -38,5 +40,9 @@ void test(int N) int main() { for (int i = 0; i < 40; ++i) - test(i); + test >(i); +#if __cplusplus >= 201103L + for (int i = 0; i < 40; ++i) + test> >(i); +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp index 794180bb..0fee4a49 100644 --- a/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp @@ -15,17 +15,19 @@ #include #include +#include "../../../min_allocator.h" + typedef int T; -typedef std::forward_list C; const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7}; const T t2[] = {10, 11, 12, 13, 14, 15}; const int size_t1 = std::end(t1) - std::begin(t1); const int size_t2 = std::end(t2) - std::begin(t2); +template void testd(const C& c, int p, int l) { - C::const_iterator i = c.begin(); + typename C::const_iterator i = c.begin(); int n1 = 0; for (; n1 < p; ++n1, ++i) assert(*i == t1[n1]); @@ -38,7 +40,9 @@ testd(const C& c, int p, int l) int main() { + { // splicing different containers + typedef std::forward_list C; for (int l = 0; l <= size_t2; ++l) { for (int p = 0; p <= size_t1; ++p) @@ -50,4 +54,22 @@ int main() testd(c1, p, l); } } + } +#if __cplusplus >= 201103L + { + // splicing different containers + typedef std::forward_list> C; + for (int l = 0; l <= size_t2; ++l) + { + for (int p = 0; p <= size_t1; ++p) + { + C c1(std::begin(t1), std::end(t1)); + C c2(t2, t2+l); + + c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2)); + testd(c1, p, l); + } + } + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp index cebb71b4..6e75d49f 100644 --- a/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp @@ -15,17 +15,19 @@ #include #include +#include "../../../min_allocator.h" + typedef int T; -typedef std::forward_list C; const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7}; const T t2[] = {10, 11, 12}; const int size_t1 = std::end(t1) - std::begin(t1); const int size_t2 = std::end(t2) - std::begin(t2); +template void testd(const C& c, int p, int f) { - C::const_iterator i = c.begin(); + typename C::const_iterator i = c.begin(); int n1 = 0; for (; n1 < p; ++n1, ++i) assert(*i == t1[n1]); @@ -36,10 +38,11 @@ testd(const C& c, int p, int f) assert(distance(c.begin(), c.end()) == size_t1 + 1); } +template void tests(const C& c, int p, int f) { - C::const_iterator i = c.begin(); + typename C::const_iterator i = c.begin(); int n = 0; int d = 1; if (p == f || p == f+1) @@ -74,7 +77,9 @@ tests(const C& c, int p, int f) int main() { + { // splicing different containers + typedef std::forward_list C; for (int f = 0; f <= size_t2-1; ++f) { for (int p = 0; p <= size_t1; ++p) @@ -100,4 +105,36 @@ int main() tests(c1, p, f); } } + } +#if __cplusplus >= 201103L + { + // splicing different containers + typedef std::forward_list> C; + for (int f = 0; f <= size_t2-1; ++f) + { + for (int p = 0; p <= size_t1; ++p) + { + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + + c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2), + next(c2.cbefore_begin(), f)); + testd(c1, p, f); + } + } + + // splicing within same container + for (int f = 0; f <= size_t1-1; ++f) + { + for (int p = 0; p <= size_t1; ++p) + { + C c1(std::begin(t1), std::end(t1)); + + c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1), + next(c1.cbefore_begin(), f)); + tests(c1, p, f); + } + } + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp index 0851ee13..0c612805 100644 --- a/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp @@ -16,17 +16,19 @@ #include #include +#include "../../../min_allocator.h" + typedef int T; -typedef std::forward_list C; const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7}; const T t2[] = {10, 11, 12, 13, 14, 15}; const int size_t1 = std::end(t1) - std::begin(t1); const int size_t2 = std::end(t2) - std::begin(t2); +template void testd(const C& c, int p, int f, int l) { - C::const_iterator i = c.begin(); + typename C::const_iterator i = c.begin(); int n1 = 0; for (; n1 < p; ++n1, ++i) assert(*i == t1[n1]); @@ -37,10 +39,11 @@ testd(const C& c, int p, int f, int l) assert(distance(c.begin(), c.end()) == size_t1 + (l > f+1 ? l-1-f : 0)); } +template void tests(const C& c, int p, int f, int l) { - C::const_iterator i = c.begin(); + typename C::const_iterator i = c.begin(); int n = 0; int d = l > f+1 ? l-1-f : 0; if (d == 0 || p == f) @@ -75,7 +78,9 @@ tests(const C& c, int p, int f, int l) int main() { + { // splicing different containers + typedef std::forward_list C; for (int f = 0; f <= size_t2+1; ++f) { for (int l = f; l <= size_t2+1; ++l) @@ -115,4 +120,50 @@ int main() } } } + } +#if __cplusplus >= 201103L + { + // splicing different containers + typedef std::forward_list> C; + for (int f = 0; f <= size_t2+1; ++f) + { + for (int l = f; l <= size_t2+1; ++l) + { + for (int p = 0; p <= size_t1; ++p) + { + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + + c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2), + next(c2.cbefore_begin(), f), next(c2.cbefore_begin(), l)); + testd(c1, p, f, l); + } + } + } + + // splicing within same container + for (int f = 0; f <= size_t1+1; ++f) + { + for (int l = f; l <= size_t1; ++l) + { + for (int p = 0; p <= f; ++p) + { + C c1(std::begin(t1), std::end(t1)); + + c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1), + next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l)); + tests(c1, p, f, l); + } + for (int p = l; p <= size_t1; ++p) + { + C c1(std::begin(t1), std::end(t1)); + + c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1), + next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l)); + tests(c1, p, f, l); + } + } + } + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp index 023fe92a..9c95dc93 100644 --- a/test/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../../min_allocator.h" + int main() { { @@ -65,4 +67,54 @@ int main() c1.unique(); assert(c1 == c2); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {0, 5, 5, 0, 0, 0, 5}; + const T t2[] = {0, 5, 0, 5}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.unique(); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {0, 0, 0, 0}; + const T t2[] = {0}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.unique(); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {5, 5, 5}; + const T t2[] = {5}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.unique(); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + C c1; + C c2; + c1.unique(); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {5, 5, 5, 0}; + const T t2[] = {5, 0}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.unique(); + assert(c1 == c2); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp index 3ac98e71..f956f270 100644 --- a/test/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "../../../min_allocator.h" + bool g(int x, int y) { return x == y; @@ -70,4 +72,54 @@ int main() c1.unique(g); assert(c1 == c2); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {0, 5, 5, 0, 0, 0, 5}; + const T t2[] = {0, 5, 0, 5}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.unique(g); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {0, 0, 0, 0}; + const T t2[] = {0}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.unique(g); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {5, 5, 5}; + const T t2[] = {5}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.unique(g); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + C c1; + C c2; + c1.unique(g); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> C; + const T t1[] = {5, 5, 5, 0}; + const T t2[] = {5, 0}; + C c1(std::begin(t1), std::end(t1)); + C c2(std::begin(t2), std::end(t2)); + c1.unique(g); + assert(c1 == c2); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp index 244ed343..485d89ef 100644 --- a/test/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp @@ -22,10 +22,12 @@ #include #include +#include "../../../min_allocator.h" + +template void test(int N, int M) { - typedef int T; - typedef std::forward_list C; + typedef typename C::value_type T; C c1; for (int i = 0; i < N; ++i) c1.push_front(i); @@ -49,5 +51,10 @@ int main() { for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) - test(i, j); + test >(i, j); +#if __cplusplus >= 201103L + for (int i = 0; i < 10; ++i) + for (int j = 0; j < 10; ++j) + test> >(i, j); +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp index 53272633..da27cc9d 100644 --- a/test/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp @@ -15,6 +15,7 @@ #include #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -175,4 +176,84 @@ int main() assert(distance(c2.begin(), c2.end()) == 0); assert(c2.get_allocator() == A(1)); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef min_allocator A; + typedef std::forward_list C; + const T t1[] = {0, 1, 2, 3, 4, 5}; + C c1(std::begin(t1), std::end(t1), A()); + const T t2[] = {10, 11, 12}; + C c2(std::begin(t2), std::end(t2), A()); + c1.swap(c2); + + assert(distance(c1.begin(), c1.end()) == 3); + assert(*next(c1.begin(), 0) == 10); + assert(*next(c1.begin(), 1) == 11); + assert(*next(c1.begin(), 2) == 12); + assert(c1.get_allocator() == A()); + + assert(distance(c2.begin(), c2.end()) == 6); + assert(*next(c2.begin(), 0) == 0); + assert(*next(c2.begin(), 1) == 1); + assert(*next(c2.begin(), 2) == 2); + assert(*next(c2.begin(), 3) == 3); + assert(*next(c2.begin(), 4) == 4); + assert(*next(c2.begin(), 5) == 5); + assert(c2.get_allocator() == A()); + } + { + typedef int T; + typedef min_allocator A; + typedef std::forward_list C; + const T t1[] = {0, 1, 2, 3, 4, 5}; + C c1(std::begin(t1), std::end(t1), A()); + C c2(A{}); + c1.swap(c2); + + assert(distance(c1.begin(), c1.end()) == 0); + assert(c1.get_allocator() == A()); + + assert(distance(c2.begin(), c2.end()) == 6); + assert(*next(c2.begin(), 0) == 0); + assert(*next(c2.begin(), 1) == 1); + assert(*next(c2.begin(), 2) == 2); + assert(*next(c2.begin(), 3) == 3); + assert(*next(c2.begin(), 4) == 4); + assert(*next(c2.begin(), 5) == 5); + assert(c2.get_allocator() == A()); + } + { + typedef int T; + typedef min_allocator A; + typedef std::forward_list C; + C c1(A{}); + const T t2[] = {10, 11, 12}; + C c2(std::begin(t2), std::end(t2), A()); + c1.swap(c2); + + assert(distance(c1.begin(), c1.end()) == 3); + assert(*next(c1.begin(), 0) == 10); + assert(*next(c1.begin(), 1) == 11); + assert(*next(c1.begin(), 2) == 12); + assert(c1.get_allocator() == A()); + + assert(distance(c2.begin(), c2.end()) == 0); + assert(c2.get_allocator() == A()); + } + { + typedef int T; + typedef min_allocator A; + typedef std::forward_list C; + C c1(A{}); + C c2(A{}); + c1.swap(c2); + + assert(distance(c1.begin(), c1.end()) == 0); + assert(c1.get_allocator() == A()); + + assert(distance(c2.begin(), c2.end()) == 0); + assert(c2.get_allocator() == A()); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp index 9963cf85..115a369e 100644 --- a/test/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp @@ -16,6 +16,7 @@ #include #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -176,4 +177,84 @@ int main() assert(distance(c2.begin(), c2.end()) == 0); assert(c2.get_allocator() == A(1)); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef min_allocator A; + typedef std::forward_list C; + const T t1[] = {0, 1, 2, 3, 4, 5}; + C c1(std::begin(t1), std::end(t1), A()); + const T t2[] = {10, 11, 12}; + C c2(std::begin(t2), std::end(t2), A()); + swap(c1, c2); + + assert(distance(c1.begin(), c1.end()) == 3); + assert(*next(c1.begin(), 0) == 10); + assert(*next(c1.begin(), 1) == 11); + assert(*next(c1.begin(), 2) == 12); + assert(c1.get_allocator() == A()); + + assert(distance(c2.begin(), c2.end()) == 6); + assert(*next(c2.begin(), 0) == 0); + assert(*next(c2.begin(), 1) == 1); + assert(*next(c2.begin(), 2) == 2); + assert(*next(c2.begin(), 3) == 3); + assert(*next(c2.begin(), 4) == 4); + assert(*next(c2.begin(), 5) == 5); + assert(c2.get_allocator() == A()); + } + { + typedef int T; + typedef min_allocator A; + typedef std::forward_list C; + const T t1[] = {0, 1, 2, 3, 4, 5}; + C c1(std::begin(t1), std::end(t1), A()); + C c2(A{}); + swap(c1, c2); + + assert(distance(c1.begin(), c1.end()) == 0); + assert(c1.get_allocator() == A()); + + assert(distance(c2.begin(), c2.end()) == 6); + assert(*next(c2.begin(), 0) == 0); + assert(*next(c2.begin(), 1) == 1); + assert(*next(c2.begin(), 2) == 2); + assert(*next(c2.begin(), 3) == 3); + assert(*next(c2.begin(), 4) == 4); + assert(*next(c2.begin(), 5) == 5); + assert(c2.get_allocator() == A()); + } + { + typedef int T; + typedef min_allocator A; + typedef std::forward_list C; + C c1(A{}); + const T t2[] = {10, 11, 12}; + C c2(std::begin(t2), std::end(t2), A()); + swap(c1, c2); + + assert(distance(c1.begin(), c1.end()) == 3); + assert(*next(c1.begin(), 0) == 10); + assert(*next(c1.begin(), 1) == 11); + assert(*next(c1.begin(), 2) == 12); + assert(c1.get_allocator() == A()); + + assert(distance(c2.begin(), c2.end()) == 0); + assert(c2.get_allocator() == A()); + } + { + typedef int T; + typedef min_allocator A; + typedef std::forward_list C; + C c1(A{}); + C c2(A{}); + swap(c1, c2); + + assert(distance(c1.begin(), c1.end()) == 0); + assert(c1.get_allocator() == A()); + + assert(distance(c2.begin(), c2.end()) == 0); + assert(c2.get_allocator() == A()); + } +#endif } diff --git a/test/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp index 717ea5a4..7823693d 100644 --- a/test/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp +++ b/test/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp @@ -30,10 +30,12 @@ #include #include +#include "../../../min_allocator.h" + +template void test(int N, int M) { - typedef int T; - typedef std::forward_list C; + typedef typename C::value_type T; C c1; for (int i = 0; i < N; ++i) c1.push_front(i); @@ -54,5 +56,10 @@ int main() { for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) - test(i, j); + test >(i, j); +#if __cplusplus >= 201103L + for (int i = 0; i < 10; ++i) + for (int j = 0; j < 10; ++j) + test> >(i, j); +#endif } diff --git a/test/containers/sequences/forwardlist/max_size.pass.cpp b/test/containers/sequences/forwardlist/max_size.pass.cpp index d942b965..96883b51 100644 --- a/test/containers/sequences/forwardlist/max_size.pass.cpp +++ b/test/containers/sequences/forwardlist/max_size.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "../../min_allocator.h" + int main() { { @@ -22,4 +24,12 @@ int main() C c; assert(c.max_size() > 0); } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + C c; + assert(c.max_size() > 0); + } +#endif } diff --git a/test/containers/sequences/forwardlist/types.pass.cpp b/test/containers/sequences/forwardlist/types.pass.cpp index d91dc69e..d812f8a9 100644 --- a/test/containers/sequences/forwardlist/types.pass.cpp +++ b/test/containers/sequences/forwardlist/types.pass.cpp @@ -28,6 +28,8 @@ #include #include +#include "../../min_allocator.h" + int main() { static_assert((std::is_same::value_type, char>::value), ""); @@ -38,4 +40,14 @@ int main() static_assert((std::is_same::const_pointer, const char*>::value), ""); static_assert((std::is_same::size_type, std::size_t>::value), ""); static_assert((std::is_same::difference_type, std::ptrdiff_t>::value), ""); +#if __cplusplus >= 201103L + static_assert((std::is_same>::value_type, char>::value), ""); + static_assert((std::is_same>::allocator_type, min_allocator >::value), ""); + static_assert((std::is_same>::reference, char&>::value), ""); + static_assert((std::is_same>::const_reference, const char&>::value), ""); + static_assert((std::is_same>::pointer, min_pointer>::value), ""); + static_assert((std::is_same>::const_pointer, min_pointer>::value), ""); + static_assert((std::is_same>::size_type, std::size_t>::value), ""); + static_assert((std::is_same>::difference_type, std::ptrdiff_t>::value), ""); +#endif }