diff --git a/libstdc++-v3/include/bits/deque.tcc b/libstdc++-v3/include/bits/deque.tcc index 3f77b4f079c..867b7c9e8d8 100644 --- a/libstdc++-v3/include/bits/deque.tcc +++ b/libstdc++-v3/include/bits/deque.tcc @@ -967,155 +967,488 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER this->_M_impl._M_finish._M_set_node(__new_nstart + __old_num_nodes - 1); } +_GLIBCXX_END_NAMESPACE_CONTAINER + // Overload for deque::iterators, exploiting the "segmented-iterator // optimization". template void - fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>& __first, - const _Deque_iterator<_Tp, _Tp&, _Tp*>& __last, const _Tp& __value) + fill(const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __first, + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __last, + const _Tp& __value) { - typedef typename _Deque_iterator<_Tp, _Tp&, _Tp*>::_Self _Self; - - for (typename _Self::_Map_pointer __node = __first._M_node + 1; - __node < __last._M_node; ++__node) - std::fill(*__node, *__node + _Self::_S_buffer_size(), __value); + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter; if (__first._M_node != __last._M_node) { std::fill(__first._M_cur, __first._M_last, __value); + + for (typename _Iter::_Map_pointer __node = __first._M_node + 1; + __node < __last._M_node; ++__node) + std::fill(*__node, *__node + _Iter::_S_buffer_size(), __value); + std::fill(__last._M_first, __last._M_cur, __value); } else std::fill(__first._M_cur, __last._M_cur, __value); } + namespace __detail + { + template + _OI + __copy_from_dit( + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*>& __first, + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*>& __last, + _OI __result) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _Iter; + + if (__first._M_node != __last._M_node) + { + __result = std::copy(__first._M_cur, __first._M_last, __result); + + for (typename _Iter::_Map_pointer __node = __first._M_node + 1; + __node != __last._M_node; ++__node) + __result = std::copy(*__node, *__node + _Iter::_S_buffer_size(), + __result); + + return std::copy(__last._M_first, __last._M_cur, __result); + } + + return std::copy(__first._M_cur, __last._M_cur, __result); + } + + template + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + __copy_to_dit(_II __first, _II __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter; + typedef typename _Iter::difference_type difference_type; + + difference_type __len = __last - __first; + while (__len > 0) + { + const difference_type __clen + = std::min(__len, __result._M_last - __result._M_cur); + std::copy(__first, __first + __clen, __result._M_cur); + + __first += __clen; + __result += __clen; + __len -= __clen; + } + + return __result; + } + + template + _OI + __copy_backward_from_dit( + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*>& __first, + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*>& __last, + _OI __result) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _Iter; + + if (__first._M_node != __last._M_node) + { + __result = std::copy_backward(__last._M_first, __last._M_cur, + __result); + + for (typename _Iter::_Map_pointer __node = __last._M_node - 1; + __node != __first._M_node; --__node) + __result + = std::copy_backward(*__node, *__node + _Iter::_S_buffer_size(), + __result); + + return std::copy_backward(__first._M_cur, __first._M_last, __result); + } + + return std::copy_backward(__first._M_cur, __last._M_cur, __result); + } + + template + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + __copy_backward_to_dit( + _II __first, _II __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter; + typedef typename _Iter::difference_type difference_type; + + difference_type __len = __last - __first; + while (__len > 0) + { + difference_type __rlen = __result._M_cur - __result._M_first; + _Tp* __rend = __result._M_cur; + if (!__rlen) + { + __rlen = _Iter::_S_buffer_size(); + __rend = *(__result._M_node - 1) + __rlen; + } + + const difference_type __clen = std::min(__len, __rlen); + std::copy_backward(__last - __clen, __last, __rend); + + __last -= __clen; + __result -= __clen; + __len -= __clen; + } + + return __result; + } + + template + bool + __equal_from_dit( + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*>& __first1, + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*>& __last1, + _II __first2) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _Iter; + + if (__first1._M_node != __last1._M_node) + { + if (!std::equal(__first1._M_cur, __first1._M_last, __first2)) + return false; + + __first2 += __first1._M_last - __first1._M_cur; + for (typename _Iter::_Map_pointer __node = __first1._M_node + 1; + __node != __last1._M_node; + __first2 += _Iter::_S_buffer_size(), ++__node) + if (!std::equal(*__node, *__node + _Iter::_S_buffer_size(), __first2)) + return false; + + return std::equal(__last1._M_first, __last1._M_cur, __first2); + } + + return std::equal(__first1._M_cur, __last1._M_cur, __first2); + } + + template + bool + __equal_to_dit(_II __first1, _II __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first2) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _Iter; + typedef typename _Iter::difference_type difference_type; + + difference_type __len = __last1 - __first1; + while (__len > 0) + { + const difference_type __clen + = std::min(__len, __first2._M_last - __first2._M_cur); + if (!std::equal(__first1, __first1 + __clen, __first2._M_cur)) + return false; + + __first1 += __clen; + __len -= __clen; + __first2 += __clen; + } + + return true; + } + +#if __cplusplus >= 201103L + template + _OI + __move_from_dit( + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*>& __first, + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*>& __last, + _OI __result) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _Iter; + + if (__first._M_node != __last._M_node) + { + __result = std::move(__first._M_cur, __first._M_last, __result); + + for (typename _Iter::_Map_pointer __node = __first._M_node + 1; + __node != __last._M_node; ++__node) + __result = std::move(*__node, *__node + _Iter::_S_buffer_size(), + __result); + + return std::move(__last._M_first, __last._M_cur, __result); + } + + return std::move(__first._M_cur, __last._M_cur, __result); + } + + template + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + __move_to_dit(_II __first, _II __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter; + typedef typename _Iter::difference_type difference_type; + + difference_type __len = __last - __first; + while (__len > 0) + { + const difference_type __clen + = std::min(__len, __result._M_last - __result._M_cur); + std::move(__first, __first + __clen, __result._M_cur); + + __first += __clen; + __result += __clen; + __len -= __clen; + } + + return __result; + } + + template + _OI + __move_backward_from_dit( + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*>& __first, + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*>& __last, + _OI __result) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _Iter; + + if (__first._M_node != __last._M_node) + { + __result = std::move_backward(__last._M_first, __last._M_cur, + __result); + + for (typename _Iter::_Map_pointer __node = __last._M_node - 1; + __node != __first._M_node; --__node) + __result + = std::move_backward(*__node, *__node + _Iter::_S_buffer_size(), + __result); + + return std::move_backward(__first._M_cur, __first._M_last, __result); + } + + return std::move_backward(__first._M_cur, __last._M_cur, __result); + } + + template + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + __move_backward_to_dit( + _II __first, _II __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter; + typedef typename _Iter::difference_type difference_type; + + difference_type __len = __last - __first; + while (__len > 0) + { + difference_type __rlen = __result._M_cur - __result._M_first; + _Tp* __rend = __result._M_cur; + if (!__rlen) + { + __rlen = _Iter::_S_buffer_size(); + __rend = *(__result._M_node - 1) + __rlen; + } + + const difference_type __clen = std::min(__len, __rlen); + std::move_backward(__last - __clen, __last, __rend); + + __last -= __clen; + __result -= __clen; + __len -= __clen; + } + + return __result; + } +#endif // C++11 + } + + template + _OI + copy(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __last, + _OI __result) + { + __glibcxx_requires_can_increment_range(__first, __last, __result); + + return __detail::__copy_from_dit(__first, __last, __result); + } + template - _Deque_iterator<_Tp, _Tp&, _Tp*> - copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first, - _Deque_iterator<_Tp, const _Tp&, const _Tp*> __last, - _Deque_iterator<_Tp, _Tp&, _Tp*> __result) + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + copy(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) { - typedef typename _Deque_iterator<_Tp, _Tp&, _Tp*>::_Self _Self; - typedef typename _Self::difference_type difference_type; + __glibcxx_requires_can_increment_range(__first, __last, __result); - difference_type __len = __last - __first; - while (__len > 0) - { - const difference_type __clen - = std::min(__len, std::min(__first._M_last - __first._M_cur, - __result._M_last - __result._M_cur)); - std::copy(__first._M_cur, __first._M_cur + __clen, __result._M_cur); - __first += __clen; - __result += __clen; - __len -= __clen; - } - return __result; + return __detail::__copy_from_dit(__first, __last, __result); + } + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + copy(_II __first, _II __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + __glibcxx_requires_can_increment_range(__first, __last, __result); + + return __detail::__copy_to_dit(__first, __last, __result); + } + + template + _OI + copy_backward( + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __last, + _OI __result) + { + __glibcxx_requires_can_decrement_range(__first, __last, __result); + + return __detail::__copy_backward_from_dit(__first, __last, __result); } template - _Deque_iterator<_Tp, _Tp&, _Tp*> - copy_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first, - _Deque_iterator<_Tp, const _Tp&, const _Tp*> __last, - _Deque_iterator<_Tp, _Tp&, _Tp*> __result) + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + copy_backward( + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) { - typedef typename _Deque_iterator<_Tp, _Tp&, _Tp*>::_Self _Self; - typedef typename _Self::difference_type difference_type; + __glibcxx_requires_can_decrement_range(__first, __last, __result); - difference_type __len = __last - __first; - while (__len > 0) - { - difference_type __llen = __last._M_cur - __last._M_first; - _Tp* __lend = __last._M_cur; + return __detail::__copy_backward_from_dit(__first, __last, __result); + } - difference_type __rlen = __result._M_cur - __result._M_first; - _Tp* __rend = __result._M_cur; + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + copy_backward(_II __first, _II __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + __glibcxx_requires_can_decrement_range(__first, __last, __result); - if (!__llen) - { - __llen = _Self::_S_buffer_size(); - __lend = *(__last._M_node - 1) + __llen; - } - if (!__rlen) - { - __rlen = _Self::_S_buffer_size(); - __rend = *(__result._M_node - 1) + __rlen; - } + return __detail::__copy_backward_to_dit(__first, __last, __result); + } - const difference_type __clen = std::min(__len, - std::min(__llen, __rlen)); - std::copy_backward(__lend - __clen, __lend, __rend); - __last -= __clen; - __result -= __clen; - __len -= __clen; - } - return __result; + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, bool>::__type + equal(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __last1, + _II __first2) + { + __glibcxx_requires_can_increment_range(__first1, __last1, __first2); + + return __detail::__equal_from_dit(__first1, __last1, __first2); } -#if __cplusplus >= 201103L template - _Deque_iterator<_Tp, _Tp&, _Tp*> - move(_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first, - _Deque_iterator<_Tp, const _Tp&, const _Tp*> __last, - _Deque_iterator<_Tp, _Tp&, _Tp*> __result) + bool + equal(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first2) { - typedef typename _Deque_iterator<_Tp, _Tp&, _Tp*>::_Self _Self; - typedef typename _Self::difference_type difference_type; + __glibcxx_requires_can_increment_range(__first1, __last1, __first2); - difference_type __len = __last - __first; - while (__len > 0) - { - const difference_type __clen - = std::min(__len, std::min(__first._M_last - __first._M_cur, - __result._M_last - __result._M_cur)); - std::move(__first._M_cur, __first._M_cur + __clen, __result._M_cur); - __first += __clen; - __result += __clen; - __len -= __clen; - } - return __result; + return __detail::__equal_from_dit(__first1, __last1, __first2); + } + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, bool>::__type + equal(_II __first1, _II __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first2) + { + __glibcxx_requires_can_increment_range(__first1, __last1, __first2); + + return __detail::__equal_to_dit(__first1, __last1, __first2); + } + +#if __cplusplus >= 201103L + template + _OI + move(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __last, + _OI __result) + { + __glibcxx_requires_can_increment_range(__first, __last, __result); + + return __detail::__move_from_dit(__first, __last, __result); } template - _Deque_iterator<_Tp, _Tp&, _Tp*> - move_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first, - _Deque_iterator<_Tp, const _Tp&, const _Tp*> __last, - _Deque_iterator<_Tp, _Tp&, _Tp*> __result) + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + move(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) { - typedef typename _Deque_iterator<_Tp, _Tp&, _Tp*>::_Self _Self; - typedef typename _Self::difference_type difference_type; + __glibcxx_requires_can_increment_range(__first, __last, __result); - difference_type __len = __last - __first; - while (__len > 0) - { - difference_type __llen = __last._M_cur - __last._M_first; - _Tp* __lend = __last._M_cur; + return __detail::__move_from_dit(__first, __last, __result); + } + + template + typename enable_if< + __is_random_access_iter<_II>::value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::type + move(_II __first, _II __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + __glibcxx_requires_can_increment_range(__first, __last, __result); - difference_type __rlen = __result._M_cur - __result._M_first; - _Tp* __rend = __result._M_cur; + return __detail::__move_to_dit(__first, __last, __result); + } - if (!__llen) - { - __llen = _Self::_S_buffer_size(); - __lend = *(__last._M_node - 1) + __llen; - } - if (!__rlen) - { - __rlen = _Self::_S_buffer_size(); - __rend = *(__result._M_node - 1) + __rlen; - } + template + _OI + move_backward( + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __last, + _OI __result) + { + __glibcxx_requires_can_decrement_range(__first, __last, __result); - const difference_type __clen = std::min(__len, - std::min(__llen, __rlen)); - std::move_backward(__lend - __clen, __lend, __rend); - __last -= __clen; - __result -= __clen; - __len -= __clen; - } - return __result; + return __detail::__move_backward_from_dit(__first, __last, __result); } -#endif -_GLIBCXX_END_NAMESPACE_CONTAINER + template + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + move_backward( + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + __glibcxx_requires_can_decrement_range(__first, __last, __result); + + return __detail::__move_backward_from_dit(__first, __last, __result); + } + + template + typename enable_if< + __is_random_access_iter<_II>::value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::type + move_backward(_II __first, _II __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + __glibcxx_requires_can_decrement_range(__first, __last, __result); + + return __detail::__move_backward_to_dit(__first, __last, __result); + } +#endif // C++11 + _GLIBCXX_END_NAMESPACE_VERSION } // namespace std diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index ac76d681ff0..ff03ec08dd6 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -370,77 +370,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { return __x + __n; } }; - template - void - fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>&, - const _Deque_iterator<_Tp, _Tp&, _Tp*>&, const _Tp&); - - template - _Deque_iterator<_Tp, _Tp&, _Tp*> - copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*>, - _Deque_iterator<_Tp, const _Tp&, const _Tp*>, - _Deque_iterator<_Tp, _Tp&, _Tp*>); - - template - inline _Deque_iterator<_Tp, _Tp&, _Tp*> - copy(_Deque_iterator<_Tp, _Tp&, _Tp*> __first, - _Deque_iterator<_Tp, _Tp&, _Tp*> __last, - _Deque_iterator<_Tp, _Tp&, _Tp*> __result) - { return std::copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__first), - _Deque_iterator<_Tp, const _Tp&, const _Tp*>(__last), - __result); } - - template - _Deque_iterator<_Tp, _Tp&, _Tp*> - copy_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*>, - _Deque_iterator<_Tp, const _Tp&, const _Tp*>, - _Deque_iterator<_Tp, _Tp&, _Tp*>); - - template - inline _Deque_iterator<_Tp, _Tp&, _Tp*> - copy_backward(_Deque_iterator<_Tp, _Tp&, _Tp*> __first, - _Deque_iterator<_Tp, _Tp&, _Tp*> __last, - _Deque_iterator<_Tp, _Tp&, _Tp*> __result) - { return std::copy_backward(_Deque_iterator<_Tp, - const _Tp&, const _Tp*>(__first), - _Deque_iterator<_Tp, - const _Tp&, const _Tp*>(__last), - __result); } - -#if __cplusplus >= 201103L - template - _Deque_iterator<_Tp, _Tp&, _Tp*> - move(_Deque_iterator<_Tp, const _Tp&, const _Tp*>, - _Deque_iterator<_Tp, const _Tp&, const _Tp*>, - _Deque_iterator<_Tp, _Tp&, _Tp*>); - - template - inline _Deque_iterator<_Tp, _Tp&, _Tp*> - move(_Deque_iterator<_Tp, _Tp&, _Tp*> __first, - _Deque_iterator<_Tp, _Tp&, _Tp*> __last, - _Deque_iterator<_Tp, _Tp&, _Tp*> __result) - { return std::move(_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__first), - _Deque_iterator<_Tp, const _Tp&, const _Tp*>(__last), - __result); } - - template - _Deque_iterator<_Tp, _Tp&, _Tp*> - move_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*>, - _Deque_iterator<_Tp, const _Tp&, const _Tp*>, - _Deque_iterator<_Tp, _Tp&, _Tp*>); - - template - inline _Deque_iterator<_Tp, _Tp&, _Tp*> - move_backward(_Deque_iterator<_Tp, _Tp&, _Tp*> __first, - _Deque_iterator<_Tp, _Tp&, _Tp*> __last, - _Deque_iterator<_Tp, _Tp&, _Tp*> __result) - { return std::move_backward(_Deque_iterator<_Tp, - const _Tp&, const _Tp*>(__first), - _Deque_iterator<_Tp, - const _Tp&, const _Tp*>(__last), - __result); } -#endif - /** * Deque base class. This class provides the unified face for %deque's * allocation. This class's constructor and destructor allocate and @@ -2343,13 +2272,258 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _GLIBCXX_END_NAMESPACE_CONTAINER + template + void + fill(const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&, + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&, + const _Tp&); + + template + _OI + copy(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _OI); + + template + inline _OI + copy(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __last, + _OI __result) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _CIter; + return std::copy(_CIter(__first), _CIter(__last), __result); + } + + template + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + copy(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>); + + template + inline _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + copy(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _CIter; + return std::copy(_CIter(__first), _CIter(__last), __result); + } + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + copy(_II, _II, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>); + + template + _OI + copy_backward(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _OI); + + template + inline _OI + copy_backward(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __last, + _OI __result) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _CIter; + return std::copy_backward(_CIter(__first), _CIter(__last), __result); + } + + template + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + copy_backward(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>); + + template + inline _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + copy_backward(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _CIter; + return std::copy_backward(_CIter(__first), _CIter(__last), __result); + } + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + copy_backward(_II, _II, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>); + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, bool>::__type + equal(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _II); + + template + inline typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, bool>::__type + equal(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __last1, + _II __first2) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _CIter; + return std::equal(_CIter(__first1), _CIter(__last1), __first2); + } + + template + bool + equal(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>); + + template + inline bool + equal(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first2) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _CIter; + return std::equal(_CIter(__first1), _CIter(__last1), __first2); + } + + template + inline bool + equal(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __first2) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _CIter; + return std::equal(__first1, __last1, _CIter(__first2)); + } + + template + inline bool + equal(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __first2) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _CIter; + return std::equal(_CIter(__first1), _CIter(__last1), _CIter(__first2)); + } + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, bool>::__type + equal(_II, _II, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>); + + template + inline typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, bool>::__type + equal(_II __first1, _II __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __first2) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _CIter; + return std::equal(__first1, __last1, _CIter(__first2)); + } + #if __cplusplus >= 201103L // std::allocator is safe, but it is not the only allocator // for which this is valid. template struct __is_bitwise_relocatable<_GLIBCXX_STD_C::deque<_Tp>> : true_type { }; -#endif + + template + _OI + move(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _OI); + + template + inline _OI + move(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __last, + _OI __result) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _CIter; + return std::move(_CIter(__first), _CIter(__last), __result); + } + + template + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + move(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>); + + template + inline _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + move(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _CIter; + return std::move(_CIter(__first), _CIter(__last), __result); + } + + template + typename enable_if< + __is_random_access_iter<_II>::value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::type + move(_II, _II, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>); + + template + _OI + move_backward(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _OI); + + template + inline _OI + move_backward(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __last, + _OI __result) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _CIter; + return std::move_backward(_CIter(__first), _CIter(__last), __result); + } + + template + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + move_backward(_GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>); + + template + inline _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> + move_backward(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + typedef + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> _CIter; + return std::move_backward(_CIter(__first), _CIter(__last), __result); + } + + template + typename enable_if< + __is_random_access_iter<_II>::value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::type + move_backward(_II, _II, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>); +#endif // C++11 _GLIBCXX_END_NAMESPACE_VERSION } // namespace std diff --git a/libstdc++-v3/include/bits/stl_iterator_base_types.h b/libstdc++-v3/include/bits/stl_iterator_base_types.h index af69dbb017a..8135f4857fc 100644 --- a/libstdc++-v3/include/bits/stl_iterator_base_types.h +++ b/libstdc++-v3/include/bits/stl_iterator_base_types.h @@ -213,6 +213,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION enable_if::iterator_category, input_iterator_tag>::value>::type; + + template, + typename _Cat = typename _Traits::iterator_category> + struct __is_random_access_iter + : is_base_of + { + typedef is_base_of _Base; + enum { __value = _Base::value }; + }; +#else + template, + typename _Cat = typename _Traits::iterator_category> + struct __is_random_access_iter + { enum { __value = __is_base_of(random_access_iterator_tag, _Cat) }; }; #endif _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque index 973f39fced6..d15156f29a4 100644 --- a/libstdc++-v3/include/debug/deque +++ b/libstdc++-v3/include/debug/deque @@ -685,6 +685,600 @@ namespace __debug { __lhs.swap(__rhs); } } // namespace __debug + +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + fill(const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> >& __first, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> >& __last, + const _Tp& __value) + { + __glibcxx_check_valid_range(__first, __last); + std::fill(__first.base(), __last.base(), __value); + } + + template + _OI + copy(const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc> >& __first, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc> >& __last, + _OI __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, __dist.first); + + return std::copy(__first.base(), __last.base(), __result); + } + + template + _OI + copy(const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> >& __first, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> >& __last, + _OI __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, __dist.first); + + return std::copy(__first.base(), __last.base(), __result); + } + + template + ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc2> > + copy(const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __first, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __last, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc2> >& __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, __dist.first); + + return ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc2> >( + std::copy(__first.base(), __last.base(), __result.base()), + __result._M_get_sequence()); + } + + template + ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc2> > + copy(const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __first, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __last, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc2> >& __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, __dist.first); + + return ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc2> >( + std::copy(__first.base(), __last.base(), __result.base()), + __result._M_get_sequence()); + } + + template + typename __gnu_cxx::__enable_if< + std::__is_random_access_iter<_II>::__value, + ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> > >::__type + copy(_II __first, _II __last, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> >& __result) + { + typename ::__gnu_debug::_Distance_traits<_II>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, __dist.first); + + return ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> >( + std::copy(::__gnu_debug::__unsafe(__first), + ::__gnu_debug::__unsafe(__last), __result.base()), + __result._M_get_sequence()); + } + + template + _OI + copy_backward( + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc> >& __first, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc> >& __last, + _OI __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, -__dist.first); + + return std::copy_backward(__first.base(), __last.base(), __result); + } + + template + inline _OI + copy_backward( + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> >& __first, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> >& __last, + _OI __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, -__dist.first); + + return std::copy_backward(__first.base(), __last.base(), __result); + } + + template + ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc2> > + copy_backward( + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __first, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __last, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc2> >& __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, -__dist.first); + + return ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc2> >( + std::copy_backward(__first.base(), __last.base(), __result.base()), + __result._M_get_sequence()); + } + + template + ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc2> > + copy_backward( + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __first, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __last, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc2> >& __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, -__dist.first); + + return ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc2> >( + std::copy_backward(__first.base(), __last.base(), __result.base()), + __result._M_get_sequence()); + } + + template + typename __gnu_cxx::__enable_if< + std::__is_random_access_iter<_II>::__value, + ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> > >::__type + copy_backward(_II __first, _II __last, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> >& __result) + { + typename ::__gnu_debug::_Distance_traits<_II>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, -__dist.first); + + return ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> >( + std::copy_backward(::__gnu_debug::__unsafe(__first), + ::__gnu_debug::__unsafe(__last), + __result.base()), + __result._M_get_sequence()); + } + + template + inline typename __gnu_cxx::__enable_if< + std::__is_random_access_iter<_II>::__value, bool>::__type + equal(const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc> >& __first1, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc> >& __last1, + _II __first2) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> >::__type + __dist; + __glibcxx_check_valid_range2(__first1, __last1, __dist); + __glibcxx_check_can_increment(__first2, __dist.first); + + return std::equal(__first1.base(), __last1.base(), + ::__gnu_debug::__unsafe(__first2)); + } + + template + inline typename __gnu_cxx::__enable_if< + std::__is_random_access_iter<_II>::__value, bool>::__type + equal(const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> >& __first1, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> >& __last1, + _II __first2) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + __dist; + __glibcxx_check_valid_range2(__first1, __last1, __dist); + __glibcxx_check_can_increment(__first2, __dist.first); + + return std::equal(__first1.base(), __last1.base(), + ::__gnu_debug::__unsafe(__first2)); + } + + template + bool + equal(const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __first1, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __last1, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc2> >& __first2) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> >::__type + __dist; + __glibcxx_check_valid_range2(__first1, __last1, __dist); + __glibcxx_check_can_increment(__first2, __dist.first); + + return std::equal(__first1.base(), __last1.base(), __first2.base()); + } + + template + bool + equal(const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __first1, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __last1, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc2> >& __first2) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + __dist; + __glibcxx_check_valid_range2(__first1, __last1, __dist); + __glibcxx_check_can_increment(__first2, __dist.first); + + return std::equal(__first1.base(), __last1.base(), __first2.base()); + } + + template + bool + equal(const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __first1, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __last1, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc2> >& __first2) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*> >::__type + __dist; + __glibcxx_check_valid_range2(__first1, __last1, __dist); + __glibcxx_check_can_increment(__first2, __dist.first); + + return std::equal(__first1.base(), __last1.base(), __first2.base()); + } + + template + bool + equal(const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __first1, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc1> >& __last1, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc2> >& __first2) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + __dist; + __glibcxx_check_valid_range2(__first1, __last1, __dist); + __glibcxx_check_can_increment(__first2, __dist.first); + + return std::equal(__first1.base(), __last1.base(), __first2.base()); + } + + template + typename __gnu_cxx::__enable_if< + std::__is_random_access_iter<_II>::__value, bool>::__type + equal(_II __first1, _II __last1, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc> >& __first2) + { + __glibcxx_check_can_increment_range(__first1, __last1, __first2); + + return std::equal(::__gnu_debug::__unsafe(__first1), + ::__gnu_debug::__unsafe(__last1), + __first2.base()); + } + + template + typename __gnu_cxx::__enable_if< + std::__is_random_access_iter<_II>::__value, bool>::__type + equal(_II __first1, _II __last1, + const ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> >& __first2) + { + __glibcxx_check_can_increment_range(__first1, __last1, __first2); + + return std::equal(::__gnu_debug::__unsafe(__first1), + ::__gnu_debug::__unsafe(__last1), + __first2.base()); + } + +#if __cplusplus >= 201103L + + namespace __detail + { + template + using _SDeque_iterator = ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>, + __debug::deque<_Tp, _Alloc> >; + + template + using _SDeque_const_iterator = ::__gnu_debug::_Safe_iterator< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, + __debug::deque<_Tp, _Alloc> >; + } + + template + _OI + move(const __detail::_SDeque_const_iterator<_Tp, _Alloc>& __first, + const __detail::_SDeque_const_iterator<_Tp, _Alloc>& __last, + _OI __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, __dist.first); + + return std::move(__first.base(), __last.base(), __result); + } + + template + _OI + move(const __detail::_SDeque_iterator<_Tp, _Alloc>& __first, + const __detail::_SDeque_iterator<_Tp, _Alloc>& __last, + _OI __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, __dist.first); + + return std::move(__first.base(), __last.base(), __result); + } + + template + __detail::_SDeque_iterator<_Tp, _Alloc2> + move(const __detail::_SDeque_const_iterator<_Tp, _Alloc1>& __first, + const __detail::_SDeque_const_iterator<_Tp, _Alloc1>& __last, + const __detail::_SDeque_iterator<_Tp, _Alloc2>& __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, __dist.first); + + return + { + std::move(__first.base(), __last.base(), __result.base()), + __result._M_get_sequence() + }; + } + + template + __detail::_SDeque_iterator<_Tp, _Alloc2> + move(const __detail::_SDeque_iterator<_Tp, _Alloc1>& __first, + const __detail::_SDeque_iterator<_Tp, _Alloc1>& __last, + const __detail::_SDeque_iterator<_Tp, _Alloc2>& __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, __dist.first); + + return + { + std::move(__first.base(), __last.base(), __result.base()), + __result._M_get_sequence() + }; + } + + template + typename enable_if< + std::__is_random_access_iter<_II>::value, + __detail::_SDeque_iterator<_Tp, _Alloc> >::type + move(_II __first, _II __last, + const __detail::_SDeque_iterator<_Tp, _Alloc>& __result) + { + typename ::__gnu_debug::_Distance_traits<_II>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, __dist.first); + + return + { + std::move(::__gnu_debug::__unsafe(__first), + ::__gnu_debug::__unsafe(__last), __result.base()), + __result._M_get_sequence() + }; + } + + template + _OI + move_backward( + const __detail::_SDeque_const_iterator<_Tp, _Alloc>& __first, + const __detail::_SDeque_const_iterator<_Tp, _Alloc>& __last, + _OI __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, -__dist.first); + + return std::move_backward(__first.base(), __last.base(), __result); + } + + template + inline _OI + move_backward(const __detail::_SDeque_iterator<_Tp, _Alloc>& __first, + const __detail::_SDeque_iterator<_Tp, _Alloc>& __last, + _OI __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, -__dist.first); + + return std::move_backward(__first.base(), __last.base(), __result); + } + + template + __detail::_SDeque_iterator<_Tp, _Alloc2> + move_backward( + const __detail::_SDeque_const_iterator<_Tp, _Alloc1>& __first, + const __detail::_SDeque_const_iterator<_Tp, _Alloc1>& __last, + const __detail::_SDeque_iterator<_Tp, _Alloc2>& __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, const _Tp&, + const _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, -__dist.first); + + return + { + std::move_backward(__first.base(), __last.base(), __result.base()), + __result._M_get_sequence() + }; + } + + template + __detail::_SDeque_iterator<_Tp, _Alloc2> + move_backward( + const __detail::_SDeque_iterator<_Tp, _Alloc1>& __first, + const __detail::_SDeque_iterator<_Tp, _Alloc1>& __last, + const __detail::_SDeque_iterator<_Tp, _Alloc2>& __result) + { + typename ::__gnu_debug::_Distance_traits< + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, -__dist.first); + + return + { + std::move_backward(__first.base(), __last.base(), __result.base()), + __result._M_get_sequence() + }; + } + + template + typename enable_if< + std::__is_random_access_iter<_II>::value, + __detail::_SDeque_iterator<_Tp, _Alloc> >::type + move_backward(_II __first, _II __last, + const __detail::_SDeque_iterator<_Tp, _Alloc>& __result) + { + typename ::__gnu_debug::_Distance_traits<_II>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment(__result, -__dist.first); + + return + { + std::move_backward(::__gnu_debug::__unsafe(__first), + ::__gnu_debug::__unsafe(__last), __result.base()), + __result._M_get_sequence() + }; + } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif diff --git a/libstdc++-v3/include/std/numeric b/libstdc++-v3/include/std/numeric index 239276946b5..0135db889c6 100644 --- a/libstdc++-v3/include/std/numeric +++ b/libstdc++-v3/include/std/numeric @@ -229,13 +229,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @addtogroup numeric_ops /// @{ - /// @cond undocumented - template, - typename _Cat = typename _Traits::iterator_category> - using __is_random_access_iter - = is_base_of; - /// @endcond - /** * @brief Calculate reduction of values in a range. * diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/11_neg.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/11_neg.cc new file mode 100644 index 00000000000..86594da0102 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/11_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size(), 0); + + std::copy(d.begin() + 10, d.begin() + 5, dest.begin()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/12_neg.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/12_neg.cc new file mode 100644 index 00000000000..1507e8903a1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/12_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size() / 2, 0); + + std::copy(d.begin(), d.end(), dest.begin()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/2.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/2.cc new file mode 100644 index 00000000000..7b0dc3d2126 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/2.cc @@ -0,0 +1,109 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +#include + +void test01() +{ + using namespace std; + + deque d; + for (int i = 0; i != _GLIBCXX_STD_C::__deque_buf_size(sizeof(int)); ++i) + d.push_back(i); + + deque dest(d.size(), 0); + + copy(d.begin(), d.end(), dest.begin()); + + VERIFY( equal(dest.begin(), dest.end(), d.begin()) ); +} + +void test02() +{ + using namespace std; + + deque d; + for (int i = 0; i != 4 * _GLIBCXX_STD_C::__deque_buf_size(sizeof(int)); ++i) + d.push_back(i); + + deque dest(d.size(), 0); + + const deque& cd = d; + copy(cd.begin(), cd.end(), dest.begin()); + + VERIFY( equal(dest.begin(), dest.end(), cd.begin()) ); +} + +void test03() +{ + using namespace std; + + deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + d.pop_front(); + d.pop_back(); + + vector dest(d.size(), 0); + + copy(d.begin(), d.end(), dest.begin()); + VERIFY( equal(dest.begin(), dest.end(), d.begin()) ); +} + +void test04() +{ + using namespace std; + + vector v; + for (int i = 0; i != 1024; ++i) + v.push_back(i); + + deque dest(v.size() - 10, 0); + + std::copy(v.begin() + 5, v.end() - 5, dest.begin()); + VERIFY( std::equal(dest.begin(), dest.end(), v.begin() + 5) ); +} + +void test05() +{ + using namespace std; + + std::list l; + for (int i = 0; i != 1024; ++i) + l.push_back(i); + + std::deque dest(l.size(), 0); + + std::copy(l.begin(), l.end(), dest.begin()); + VERIFY( std::equal(dest.begin(), dest.end(), l.begin()) ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/21_neg.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/21_neg.cc new file mode 100644 index 00000000000..fc09f661b25 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/21_neg.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size(), 0); + + const std::deque& cd = d; + copy(cd.begin() + 10, cd.begin() + 5, dest.begin()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/22_neg.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/22_neg.cc new file mode 100644 index 00000000000..64ff6c487e3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/22_neg.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size() / 2, 0); + + const std::deque& cd = d; + copy(cd.begin(), cd.end(), dest.begin()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/31.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/31.cc new file mode 100644 index 00000000000..ae2c33b1d10 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/31.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::vector dest(d.size(), 0); + + const std::deque& cd = d; + std::copy(cd.begin() + 10, cd.begin() + 5, dest.begin()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/32.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/32.cc new file mode 100644 index 00000000000..8028bd6b542 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/32.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::vector dest(d.size() / 2, 0); + + const std::deque& cd = d; + std::copy(cd.begin(), cd.end(), dest.begin()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/33.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/33.cc new file mode 100644 index 00000000000..1633fafd20c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/33.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::list dest(d.size(), 0); + + const std::deque& cd = d; + std::copy(cd.begin(), cd.end(), dest.begin()); +} + +void test02() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::list dest(d.size() / 2, 0); + std::list::iterator lit = dest.begin(); + + const std::deque& cd = d; + std::copy(cd.begin(), cd.end(), ++lit); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/41.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/41.cc new file mode 100644 index 00000000000..0c9d949807a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/41.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::vector dest(d.size(), 0); + + std::copy(d.begin() + 10, d.begin() + 5, dest.begin()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/42.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/42.cc new file mode 100644 index 00000000000..c7e0c1f49fd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/42.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::vector dest(d.size() / 2, 0); + + std::copy(d.begin(), d.end(), dest.begin()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/43.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/43.cc new file mode 100644 index 00000000000..2f29afae09f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/43.cc @@ -0,0 +1,55 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::list dest(d.size(), 0); + + std::copy(d.begin(), d.end(), dest.begin()); +} + +void test02() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::list dest(d.size() / 2, 0); + std::list::iterator lit = dest.begin(); + + std::copy(d.begin(), d.end(), ++lit); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/51_neg.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/51_neg.cc new file mode 100644 index 00000000000..eaaa8b3d2d6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/51_neg.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::vector dest; + + const std::deque& cd = d; + std::copy(cd.begin() + 10, cd.begin() + 5, std::back_inserter(dest)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/61_neg.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/61_neg.cc new file mode 100644 index 00000000000..f6b20f6ee0e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/61_neg.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::vector dest; + + std::copy(d.begin() + 10, d.begin() + 5, std::back_inserter(dest)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/71_neg.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/71_neg.cc new file mode 100644 index 00000000000..063acf096f6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/71_neg.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include +#include + +#include + +void test01() +{ + std::vector v; + for (int i = 0; i != 1024; ++i) + v.push_back(i); + + std::deque dest(v.size(), 0); + + std::copy(v.begin() + 10, v.begin() + 5, dest.begin()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/72_neg.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/72_neg.cc new file mode 100644 index 00000000000..855957ae1b6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/72_neg.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include +#include + +#include + +void test01() +{ + std::vector v; + for (int i = 0; i != 1024; ++i) + v.push_back(i); + + std::deque dest(v.size() / 2, 0); + + std::copy(v.begin(), v.end(), dest.begin()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/11_neg.cc b/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/11_neg.cc new file mode 100644 index 00000000000..a497267f04f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/11_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size(), 0); + + std::copy_backward(d.begin() + 10, d.begin() + 5, dest.end()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/12_neg.cc b/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/12_neg.cc new file mode 100644 index 00000000000..f30d9f3c3b7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/12_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size() / 2, 0); + + std::copy_backward(d.begin(), d.end(), dest.end()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/2.cc b/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/2.cc new file mode 100644 index 00000000000..ccde5279859 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/2.cc @@ -0,0 +1,109 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +#include + +void test01() +{ + using namespace std; + + deque d; + for (int i = 0; i != _GLIBCXX_STD_C::__deque_buf_size(sizeof(int)); ++i) + d.push_back(i); + + deque dest(d.size(), 0); + + copy_backward(d.begin(), d.end(), dest.end()); + + VERIFY( equal(dest.begin(), dest.end(), d.begin()) ); +} + +void test02() +{ + using namespace std; + + deque d; + for (int i = 0; i != 4 * _GLIBCXX_STD_C::__deque_buf_size(sizeof(int)); ++i) + d.push_back(i); + + deque dest(d.size(), 0); + + const deque& cd = d; + copy_backward(cd.begin(), cd.end(), dest.end()); + + VERIFY( equal(dest.begin(), dest.end(), cd.begin()) ); +} + +void test03() +{ + using namespace std; + + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + d.pop_front(); + d.pop_back(); + + std::vector dest(d.size(), 0); + + std::copy_backward(d.begin(), d.end(), dest.end()); + VERIFY( std::equal(dest.begin(), dest.end(), d.begin()) ); +} + +void test04() +{ + using namespace std; + + std::vector v; + for (int i = 0; i != 1024; ++i) + v.push_back(i); + + std::deque dest(v.size() - 10, 0); + + std::copy_backward(v.begin() + 5, v.end() - 5, dest.end()); + VERIFY( std::equal(v.begin() + 5, v.end() - 5, dest.begin()) ); +} + +void test05() +{ + using namespace std; + + std::list l; + for (int i = 0; i != 1024; ++i) + l.push_back(i); + + std::deque dest(l.size(), 0); + + std::copy_backward(l.begin(), l.end(), dest.end()); + VERIFY( std::equal(dest.begin(), dest.end(), l.begin()) ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/21_neg.cc b/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/21_neg.cc new file mode 100644 index 00000000000..aec11a81172 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/21_neg.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size(), 0); + + const std::deque& cd = d; + copy_backward(cd.begin() + 10, cd.begin() + 5, dest.end()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/22_neg.cc b/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/22_neg.cc new file mode 100644 index 00000000000..89db2024ac9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/22_neg.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size() / 2, 0); + + const std::deque& cd = d; + copy_backward(cd.begin(), cd.end(), dest.end()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/1.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/1.cc new file mode 100644 index 00000000000..b99cf1df538 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/1.cc @@ -0,0 +1,122 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +#include +#include + +#include + +void test01() +{ + using namespace std; + + deque d; + for (int i = 0; i != _GLIBCXX_STD_C::__deque_buf_size(sizeof(int)); ++i) + d.push_back(i); + + const deque& cd = d; + + VERIFY( equal(cd.begin(), cd.end(), cd.begin()) ); + VERIFY( equal(cd.begin(), cd.end(), d.begin()) ); + VERIFY( equal(d.begin(), d.end(), d.begin()) ); + VERIFY( equal(d.begin(), d.end(), cd.begin()) ); +} + +void test02() +{ + using namespace std; + + deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i % 10); + + VERIFY( equal(d.begin(), d.begin() + 10, d.begin() + 20) ); + VERIFY( equal(d.begin() + 10, d.end() - 10, d.begin()) ); + + const deque& cd = d; + + VERIFY( equal(cd.begin(), cd.begin() + 10, cd.begin() + 20) ); + VERIFY( equal(cd.begin() + 10, cd.end() - 10, d.begin()) ); + VERIFY( equal(d.begin() + 10, d.end() - 10, cd.begin()) ); +} + +void test03() +{ + using namespace std; + + deque d1; + for (int i = 0; i != 1024; ++i) + d1.push_back(i % 10); + + deque d2(d1); + for (int i = 0; i != 10; ++i) + d2.pop_front(); + + VERIFY( equal(d1.begin(), d1.begin() + 10, d2.begin()) ); + VERIFY( equal(d1.begin() + 10, d1.end() - 10, d2.begin()) ); + + const deque& cd1 = d1; + const deque& cd2 = d2; + + VERIFY( equal(cd1.begin(), cd1.begin() + 10, cd2.begin() + 20) ); + VERIFY( equal(cd1.begin() + 10, cd1.end() - 10, d2.begin()) ); + VERIFY( equal(cd2.begin() + 10, cd2.end() - 10, cd1.begin()) ); +} + +void test04() +{ + using namespace std; + + deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + vector v(d.begin(), d.end()); + + VERIFY( equal(d.begin(), d.end(), v.begin()) ); + VERIFY( equal(v.begin(), v.end(), d.begin()) ); + + const deque& cd = d; + + VERIFY( equal(cd.begin(), cd.end(), v.begin()) ); + VERIFY( equal(v.begin(), v.end(), cd.begin()) ); +} + +void test05() +{ + using namespace std; + + int a[] { 0, 1, 2, 3, 4 }; + deque > d1(a, a + 5); + deque > d2(a, a + 5); + + VERIFY( equal(d1.begin(), d1.end(), d2.begin()) ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/10_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/10_neg.cc new file mode 100644 index 00000000000..72f070b292d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/10_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + const deque& cd = d; + + VERIFY( equal(cd.begin(), cd.end(), d.begin() + 2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/11_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/11_neg.cc new file mode 100644 index 00000000000..ae11f23d3b0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/11_neg.cc @@ -0,0 +1,40 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + + VERIFY( equal(d.begin() + 2, d.begin(), d.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/12_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/12_neg.cc new file mode 100644 index 00000000000..a0c2cece818 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/12_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + const deque& cd = d; + + VERIFY( equal(d.begin(), d.end(), d.begin() + 2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/13_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/13_neg.cc new file mode 100644 index 00000000000..b6f8519b1b2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/13_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + const deque& cd = d; + + VERIFY( equal(a + 2, a, cd.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/14_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/14_neg.cc new file mode 100644 index 00000000000..6dfea283516 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/14_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + const deque& cd = d; + + VERIFY( equal(a, a + 3, cd.begin() + 2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/15_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/15_neg.cc new file mode 100644 index 00000000000..fe0360a1842 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/15_neg.cc @@ -0,0 +1,40 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + + VERIFY( equal(a + 2, a, d.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/16_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/16_neg.cc new file mode 100644 index 00000000000..8330edc9b2e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/16_neg.cc @@ -0,0 +1,40 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + + VERIFY( equal(a, a + 3, d.begin() + 2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/1_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/1_neg.cc new file mode 100644 index 00000000000..1f26672b31d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/1_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + const deque& cd = d; + + VERIFY( equal(cd.begin() + 2, cd.begin(), a) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/2_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/2_neg.cc new file mode 100644 index 00000000000..caadc2b77d1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/2_neg.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + const deque& cd = d; + vector v; + + VERIFY( equal(cd.begin(), cd.end(), v.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/3_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/3_neg.cc new file mode 100644 index 00000000000..55ed05c0ae5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/3_neg.cc @@ -0,0 +1,40 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + + VERIFY( equal(d.begin() + 2, d.begin(), a) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/4_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/4_neg.cc new file mode 100644 index 00000000000..e67d4b19b42 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/4_neg.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + vector v; + + VERIFY( equal(d.begin(), d.end(), v.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/5_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/5_neg.cc new file mode 100644 index 00000000000..d737aa2edfc --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/5_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + const deque& cd = d; + + VERIFY( equal(cd.begin() + 2, cd.begin(), cd.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/6_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/6_neg.cc new file mode 100644 index 00000000000..d1a74dd068a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/6_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + const deque& cd = d; + + VERIFY( equal(cd.begin(), cd.end(), cd.begin() + 2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/7_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/7_neg.cc new file mode 100644 index 00000000000..e3c9cf1325f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/7_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + const deque& cd = d; + + VERIFY( equal(d.begin() + 2, d.begin(), cd.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/8_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/8_neg.cc new file mode 100644 index 00000000000..6078f598447 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/8_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + const deque& cd = d; + + VERIFY( equal(d.begin(), d.end(), cd.begin() + 2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/9_neg.cc b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/9_neg.cc new file mode 100644 index 00000000000..7dd86ce3ec8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/deque_iterators/9_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + int a[] { 0, 1, 2 }; + deque d(a, a + 3); + const deque& cd = d; + + VERIFY( equal(cd.begin() + 2, cd.begin(), d.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/deque_iterators/1.cc b/libstdc++-v3/testsuite/25_algorithms/fill/deque_iterators/1.cc new file mode 100644 index 00000000000..604ccb67fcd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill/deque_iterators/1.cc @@ -0,0 +1,58 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +#include + +void test01() +{ + using namespace std; + + deque d1; + for (int i = 0; i != _GLIBCXX_STD_C::__deque_buf_size(sizeof(char)); ++i) + d1.push_back((char)i); + + deque d2(d1.size(), '\0'); + + fill(d1.begin(), d1.end(), '\0'); + + VERIFY( equal(d1.begin(), d1.end(), d2.begin()) ); +} + +void test02() +{ + using namespace std; + + deque d1; + for (int i = 0; i != 4 * _GLIBCXX_STD_C::__deque_buf_size(sizeof(char)); ++i) + d1.push_back(i); + + deque d2(d1.size(), '\0'); + + fill(d1.begin(), d1.end(), '\0'); + + VERIFY( equal(d1.begin(), d1.end(), d2.begin()) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/deque_iterators/1_neg.cc b/libstdc++-v3/testsuite/25_algorithms/fill/deque_iterators/1_neg.cc new file mode 100644 index 00000000000..af25b2ef08a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill/deque_iterators/1_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + using namespace std; + + deque d; + for (int i = 0; i != _GLIBCXX_STD_C::__deque_buf_size(sizeof(char)); ++i) + d.push_back((char)i); + + fill(d.begin() + 10, d.begin() + 5, '\0'); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/11_neg.cc b/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/11_neg.cc new file mode 100644 index 00000000000..d3dc432ff7b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/11_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size(), 0); + + std::move(d.begin() + 10, d.begin() + 5, dest.begin()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/12_neg.cc b/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/12_neg.cc new file mode 100644 index 00000000000..b4079691b7c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/12_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size() / 2, 0); + + std::move(d.begin(), d.end(), dest.begin()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/2.cc b/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/2.cc new file mode 100644 index 00000000000..1f7930036d1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/2.cc @@ -0,0 +1,101 @@ +// { dg-do run { target c++11 } } +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +#include + +void test01() +{ + using namespace std; + + deque d; + for (int i = 0; i != _GLIBCXX_STD_C::__deque_buf_size(sizeof(int)); ++i) + d.push_back(i); + + deque dest(d.size(), 0); + + move(d.begin(), d.end(), dest.begin()); + + VERIFY( equal(dest.begin(), dest.end(), d.begin()) ); +} + +void test02() +{ + using namespace std; + + deque d; + for (int i = 0; i != 4 * _GLIBCXX_STD_C::__deque_buf_size(sizeof(int)); ++i) + d.push_back(i); + + deque dest(d.size(), 0); + + const deque& cd = d; + move(cd.begin(), cd.end(), dest.begin()); + + VERIFY( equal(dest.begin(), dest.end(), cd.begin()) ); +} + +void test03() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::vector dest(d.size(), 0); + + std::move(d.begin(), d.end(), dest.begin()); + VERIFY( std::equal(dest.begin(), dest.end(), d.begin()) ); +} + +void test04() +{ + std::vector v; + for (int i = 0; i != 1024; ++i) + v.push_back(i); + + std::deque dest(v.size() - 10, 0); + + std::move(v.begin() + 5, v.end() - 5, dest.begin()); + VERIFY( std::equal(dest.begin(), dest.end(), v.begin() + 5) ); +} + +void test05() +{ + std::list l; + for (int i = 0; i != 1024; ++i) + l.push_back(i); + + std::deque dest(l.size(), 0); + + std::move(l.begin(), l.end(), dest.begin()); + VERIFY( std::equal(dest.begin(), dest.end(), l.begin()) ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/21_neg.cc b/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/21_neg.cc new file mode 100644 index 00000000000..66245fb677b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/21_neg.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size(), 0); + + const std::deque& cd = d; + move(cd.begin() + 10, cd.begin() + 5, dest.begin()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/22_neg.cc b/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/22_neg.cc new file mode 100644 index 00000000000..ab69e9bab77 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/22_neg.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size() / 2, 0); + + const std::deque& cd = d; + move(cd.begin(), cd.end(), dest.begin()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/11_neg.cc b/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/11_neg.cc new file mode 100644 index 00000000000..c5dbc14f8cc --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/11_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size(), 0); + + std::move_backward(d.begin() + 10, d.begin() + 5, dest.end()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/12_neg.cc b/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/12_neg.cc new file mode 100644 index 00000000000..5718b5df141 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/12_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size() / 2, 0); + + std::move_backward(d.begin(), d.end(), dest.end()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/2.cc b/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/2.cc new file mode 100644 index 00000000000..82fff3e20c8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/2.cc @@ -0,0 +1,101 @@ +// { dg-do run { target c++11 } } +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +#include + +void test01() +{ + using namespace std; + + deque d; + for (int i = 0; i != _GLIBCXX_STD_C::__deque_buf_size(sizeof(int)); ++i) + d.push_back(i); + + deque dest(d.size(), 0); + + move_backward(d.begin(), d.end(), dest.end()); + + VERIFY( equal(dest.begin(), dest.end(), d.begin()) ); +} + +void test02() +{ + using namespace std; + + deque d; + for (int i = 0; i != 4 * _GLIBCXX_STD_C::__deque_buf_size(sizeof(int)); ++i) + d.push_back(i); + + deque dest(d.size(), 0); + + const deque& cd = d; + move_backward(cd.begin(), cd.end(), dest.end()); + + VERIFY( equal(dest.begin(), dest.end(), cd.begin()) ); +} + +void test03() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::vector dest(d.size(), 0); + + std::move_backward(d.begin(), d.end(), dest.end()); + VERIFY( std::equal(dest.begin(), dest.end(), d.begin()) ); +} + +void test04() +{ + std::vector v; + for (int i = 0; i != 1024; ++i) + v.push_back(i); + + std::deque dest(v.size() - 10, 0); + + std::move_backward(v.begin() + 5, v.end() - 5, dest.end()); + VERIFY( std::equal(dest.begin(), dest.end(), v.begin() + 5) ); +} + +void test05() +{ + std::list l; + for (int i = 0; i != 1024; ++i) + l.push_back(i); + + std::deque dest(l.size(), 0); + + std::move_backward(l.begin(), l.end(), dest.end()); + VERIFY( std::equal(dest.begin(), dest.end(), l.begin()) ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/21_neg.cc b/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/21_neg.cc new file mode 100644 index 00000000000..002d879928e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/21_neg.cc @@ -0,0 +1,40 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size(), 0); + move_backward(d.cbegin() + 10, d.cbegin() + 5, dest.end()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/22_neg.cc b/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/22_neg.cc new file mode 100644 index 00000000000..44cdfc84793 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/22_neg.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void test01() +{ + std::deque d; + for (int i = 0; i != 1024; ++i) + d.push_back(i); + + std::deque dest(d.size() / 2, 0); + + move_backward(d.cbegin(), d.cend(), dest.end()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/performance/25_algorithms/copy_backward_deque_iterators.cc b/libstdc++-v3/testsuite/performance/25_algorithms/copy_backward_deque_iterators.cc index 461dfc044ad..716907c1a96 100644 --- a/libstdc++-v3/testsuite/performance/25_algorithms/copy_backward_deque_iterators.cc +++ b/libstdc++-v3/testsuite/performance/25_algorithms/copy_backward_deque_iterators.cc @@ -16,6 +16,9 @@ // . #include +#include +#include + #include int main() @@ -34,7 +37,71 @@ int main() for (int j = 0; j < 3000; ++j) std::copy_backward(data.begin(), data.begin() + j, d.end()); stop_counters(time, resource); - report_performance(__FILE__, "", time, resource); + report_performance(__FILE__, "deque 2 deque", time, resource); + clear_counters(time, resource); + + std::vector v(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::copy_backward(data.begin(), data.begin() + j, v.end()); + stop_counters(time, resource); + report_performance(__FILE__, "deque 2 vector", time, resource); + clear_counters(time, resource); + + d.assign(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::copy_backward(v.begin(), v.begin() + j, d.end()); + stop_counters(time, resource); + report_performance(__FILE__, "vector 2 deque", time, resource); + clear_counters(time, resource); + + std::vector cv(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::copy_backward(data.begin(), data.begin() + j, cv.end()); + stop_counters(time, resource); + report_performance(__FILE__, "int deque 2 char vector", time, resource); + clear_counters(time, resource); + + d.assign(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::copy_backward(cv.begin(), cv.begin() + j, d.end()); + stop_counters(time, resource); + report_performance(__FILE__, "char vector 2 int deque", time, resource); + clear_counters(time, resource); + + std::list l(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::copy_backward(data.begin(), data.begin() + j, l.end()); + stop_counters(time, resource); + report_performance(__FILE__, "deque 2 list", time, resource); + clear_counters(time, resource); + + d.assign(3000, 1); + + std::list::iterator lit; + start_counters(time, resource); + for (int i = 0; i < 200; ++i) + { + lit = l.begin(); + for (int j = 0; j < 3000; ++j, ++lit) + std::copy_backward(l.begin(), lit, d.end()); + } + stop_counters(time, resource); + report_performance(__FILE__, "list 2 deque", time, resource); return 0; } diff --git a/libstdc++-v3/testsuite/performance/25_algorithms/copy_deque_iterators.cc b/libstdc++-v3/testsuite/performance/25_algorithms/copy_deque_iterators.cc index 35d5d79dec9..0bb2c55a950 100644 --- a/libstdc++-v3/testsuite/performance/25_algorithms/copy_deque_iterators.cc +++ b/libstdc++-v3/testsuite/performance/25_algorithms/copy_deque_iterators.cc @@ -16,6 +16,9 @@ // . #include +#include +#include + #include int main() @@ -34,7 +37,71 @@ int main() for (int j = 0; j < 3000; ++j) std::copy(data.begin(), data.begin() + j, d.begin()); stop_counters(time, resource); - report_performance(__FILE__, "", time, resource); + report_performance(__FILE__, "deque 2 deque", time, resource); + clear_counters(time, resource); + + std::vector v(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::copy(data.begin(), data.begin() + j, v.begin()); + stop_counters(time, resource); + report_performance(__FILE__, "deque 2 vector", time, resource); + clear_counters(time, resource); + + d.assign(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::copy(v.begin(), v.begin() + j, d.begin()); + stop_counters(time, resource); + report_performance(__FILE__, "vector 2 deque", time, resource); + clear_counters(time, resource); + + std::vector cv(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::copy(data.begin(), data.begin() + j, cv.begin()); + stop_counters(time, resource); + report_performance(__FILE__, "int deque 2 char vector", time, resource); + clear_counters(time, resource); + + d.assign(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::copy(cv.begin(), cv.begin() + j, d.begin()); + stop_counters(time, resource); + report_performance(__FILE__, "char vector 2 int deque", time, resource); + clear_counters(time, resource); + + std::list l(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::copy(data.begin(), data.begin() + j, l.begin()); + stop_counters(time, resource); + report_performance(__FILE__, "deque 2 list", time, resource); + clear_counters(time, resource); + + d.assign(3000, 1); + + std::list::iterator lit; + start_counters(time, resource); + for (int i = 0; i < 200; ++i) + { + lit = l.begin(); + for (int j = 0; j < 3000; ++j, ++lit) + std::copy(l.begin(), lit, d.begin()); + } + stop_counters(time, resource); + report_performance(__FILE__, "list 2 deque", time, resource); return 0; } diff --git a/libstdc++-v3/testsuite/performance/25_algorithms/equal_deque_iterators.cc b/libstdc++-v3/testsuite/performance/25_algorithms/equal_deque_iterators.cc new file mode 100644 index 00000000000..66c4601c5f6 --- /dev/null +++ b/libstdc++-v3/testsuite/performance/25_algorithms/equal_deque_iterators.cc @@ -0,0 +1,82 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +#include + +int main() +{ + using namespace __gnu_test; + + time_counter time; + resource_counter resource; + + const std::deque data(3000, 1); + + std::deque d(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::equal(data.begin(), data.begin() + j, d.begin()); + stop_counters(time, resource); + report_performance(__FILE__, "deque vs deque", time, resource); + clear_counters(time, resource); + + std::vector v(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::equal(data.begin(), data.begin() + j, v.begin()); + stop_counters(time, resource); + report_performance(__FILE__, "deque vs vector", time, resource); + clear_counters(time, resource); + + d.assign(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::equal(v.begin(), v.begin() + j, d.begin()); + stop_counters(time, resource); + report_performance(__FILE__, "vector vs deque", time, resource); + clear_counters(time, resource); + + std::vector cv(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::equal(data.begin(), data.begin() + j, cv.begin()); + stop_counters(time, resource); + report_performance(__FILE__, "int deque vs char vector", time, resource); + clear_counters(time, resource); + + d.assign(3000, 1); + + start_counters(time, resource); + for (int i = 0; i < 1000; ++i) + for (int j = 0; j < 3000; ++j) + std::equal(cv.begin(), cv.begin() + j, d.begin()); + stop_counters(time, resource); + report_performance(__FILE__, "char vector vs int deque", time, resource); + + return 0; +}