diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-10-07 11:14:11 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-10-07 11:14:11 +0000 |
commit | fa9ecc47e472ab762b512cb10724490df63977e1 (patch) | |
tree | db0f68e1e2e8c70e090187aac47f22a57f657970 /libstdc++-v3/include/bits | |
parent | 8e9253759f3473ba68d0887bc008e276f6441593 (diff) | |
download | ppe42-gcc-fa9ecc47e472ab762b512cb10724490df63977e1.tar.gz ppe42-gcc-fa9ecc47e472ab762b512cb10724490df63977e1.zip |
2007-10-07 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_algobase.h (_GLIBCXX_MOVE): Add.
(swap, __iter_swap): Use it.
* testsuite/25_algorithms/rotate/moveable.cc: Remove dg-require-rvalref.
* testsuite/25_algorithms/remove/moveable.cc: Likewise.
* testsuite/25_algorithms/partition/moveable.cc: Likewise.
* testsuite/25_algorithms/swap_ranges/moveable.cc: Likewise.
* testsuite/25_algorithms/reverse/moveable.cc: Likewise.
* testsuite/25_algorithms/unique/moveable.cc: Likewise.
* testsuite/25_algorithms/remove_if/moveable.cc: Likewise.
* include/bits/stl_algobase.h (lexicographical_compare):
Clean up.
2007-10-07 Chris Jefferson <chris@bubblescope.net>
Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_algo.h (remove, remove_if, unique,
__rotate(_RandomAccessIterator, _RandomAccessIterator,
_RandomAccessIterator, random_access_iterator_tag)): Use _GLIBCXX_MOVE.
(__rotate(_ForwardIterator, _ForwardIterator, _ForwardIterator,
forward_iterator_tag), __rotate(_BidirectionalIterator,
_BidirectionalIterator, _BidirectionalIterator,
bidirectional_iterator_tag), __partition(_ForwardIterator,
_ForwardIterator, _Predicate, forward_iterator_tag)): Use iter_swap.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129068 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/bits')
-rw-r--r-- | libstdc++-v3/include/bits/stl_algo.h | 59 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_algobase.h | 28 |
2 files changed, 52 insertions, 35 deletions
diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index cd14190d740..a5b99c5a076 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -788,9 +788,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __glibcxx_requires_valid_range(__first, __last); __first = _GLIBCXX_STD_P::find(__first, __last, __value); - _ForwardIterator __i = __first; - return __first == __last ? __first - : std::remove_copy(++__i, __last, __first, __value); + if(__first == __last) + return __first; + _ForwardIterator __result = __first; + ++__first; + for(; __first != __last; ++__first) + if(!(*__first == __value)) + { + *__result = _GLIBCXX_MOVE(*__first); + ++__result; + } + return __result; } /** @@ -822,10 +830,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __glibcxx_requires_valid_range(__first, __last); __first = _GLIBCXX_STD_P::find_if(__first, __last, __pred); - _ForwardIterator __i = __first; - return __first == __last ? __first - : std::remove_copy_if(++__i, __last, - __first, __pred); + if(__first == __last) + return __first; + _ForwardIterator __result = __first; + ++__first; + for(; __first != __last; ++__first) + if(!__pred(*__first)) + { + *__result = _GLIBCXX_MOVE(*__first); + ++__result; + } + return __result; } /** @@ -862,7 +877,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ++__first; while (++__first != __last) if (!(*__dest == *__first)) - *++__dest = *__first; + *++__dest = _GLIBCXX_MOVE(*__first); return ++__dest; } @@ -903,7 +918,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ++__first; while (++__first != __last) if (!bool(__binary_pred(*__dest, *__first))) - *++__dest = *__first; + *++__dest = _GLIBCXX_MOVE(*__first); return ++__dest; } @@ -1207,7 +1222,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _ForwardIterator __first2 = __middle; do { - swap(*__first, *__first2); + std::iter_swap(__first, __first2); ++__first; ++__first2; if (__first == __middle) @@ -1219,7 +1234,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) while (__first2 != __last) { - swap(*__first, *__first2); + std::iter_swap(__first, __first2); ++__first; ++__first2; if (__first == __middle) @@ -1253,7 +1268,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) while (__first != __middle && __middle != __last) { - swap(*__first, *--__last); + std::iter_swap(__first, --__last); ++__first; } @@ -1301,7 +1316,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) for (_Distance __i = 0; __i < __d; __i++) { - _ValueType __tmp = *__first; + _ValueType __tmp = _GLIBCXX_MOVE(*__first); _RandomAccessIterator __p = __first; if (__k < __l) @@ -1310,11 +1325,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { if (__p > __first + __l) { - *__p = *(__p - __l); + *__p = _GLIBCXX_MOVE(*(__p - __l)); __p -= __l; } - *__p = *(__p + __k); + *__p = _GLIBCXX_MOVE(*(__p + __k)); __p += __k; } } @@ -1324,15 +1339,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { if (__p < __last - __k) { - *__p = *(__p + __k); + *__p = _GLIBCXX_MOVE(*(__p + __k)); __p += __k; } - *__p = * (__p - __l); + *__p = _GLIBCXX_MOVE(*(__p - __l)); __p -= __l; } } - *__p = __tmp; + *__p = _GLIBCXX_MOVE(__tmp); ++__first; } } @@ -1412,8 +1427,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template<typename _ForwardIterator, typename _Predicate> _ForwardIterator __partition(_ForwardIterator __first, _ForwardIterator __last, - _Predicate __pred, - forward_iterator_tag) + _Predicate __pred, forward_iterator_tag) { if (__first == __last) return __first; @@ -1427,7 +1441,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) while (++__next != __last) if (__pred(*__next)) { - swap(*__first, *__next); + std::iter_swap(__first, __next); ++__first; } @@ -1442,8 +1456,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template<typename _BidirectionalIterator, typename _Predicate> _BidirectionalIterator __partition(_BidirectionalIterator __first, _BidirectionalIterator __last, - _Predicate __pred, - bidirectional_iterator_tag) + _Predicate __pred, bidirectional_iterator_tag) { while (true) { diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index c6648b43b9d..e0e285088d6 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -74,6 +74,13 @@ #include <bits/concept_check.h> #include <debug/debug.h> +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +# include <utility> +# define _GLIBCXX_MOVE(_Tp) std::move(_Tp) +#else +# define _GLIBCXX_MOVE(_Tp) _Tp +#endif + _GLIBCXX_BEGIN_NAMESPACE(std) /** @@ -92,9 +99,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // concept requirements __glibcxx_function_requires(_SGIAssignableConcept<_Tp>) - _Tp __tmp = __a; - __a = __b; - __b = __tmp; + _Tp __tmp = _GLIBCXX_MOVE(__a); + __a = _GLIBCXX_MOVE(__b); + __b = _GLIBCXX_MOVE(__tmp); } // See http://gcc.gnu.org/ml/libstdc++/2004-08/msg00167.html: in a @@ -109,9 +116,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { typedef typename iterator_traits<_ForwardIterator1>::value_type _ValueType1; - _ValueType1 __tmp = *__a; - *__a = *__b; - *__b = __tmp; + _ValueType1 __tmp = _GLIBCXX_MOVE(*__a); + *__a = _GLIBCXX_MOVE(*__b); + *__b = _GLIBCXX_MOVE(__tmp); } }; @@ -879,6 +886,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P) { typedef typename iterator_traits<_II1>::iterator_category _Category1; typedef typename iterator_traits<_II2>::iterator_category _Category2; + typedef __lc_rai<_Category1, _Category2> __rai_type; // concept requirements typedef typename iterator_traits<_II1>::value_type _ValueType1; @@ -890,12 +898,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P) __glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first2, __last2); - __last1 = __lc_rai<_Category1, _Category2>::__newlast1(__first1, - __last1, - __first2, - __last2); - for (; __first1 != __last1 - && __lc_rai<_Category1, _Category2>::__cnd2(__first2, __last2); + __last1 = __rai_type::__newlast1(__first1, __last1, __first2, __last2); + for (; __first1 != __last1 && __rai_type::__cnd2(__first2, __last2); ++__first1, ++__first2) { if (*__first1 < *__first2) |