Commit d385563f by Paolo Carlini Committed by Paolo Carlini

re PR libstdc++/42352 (-std=c++0x reference binding problem)

2009-12-11  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/42352
	* include/bits/list.tcc (sort): Use _GLIBCXX_MOVE for list::splice
	and list::merge calls.
	* testsuite/23_containers/list/operations/42352.cc: New.

From-SVN: r155180
parent dcea1b2f
2009-12-11 Paolo Carlini <paolo.carlini@oracle.com> 2009-12-11 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/42352
* include/bits/list.tcc (sort): Use _GLIBCXX_MOVE for list::splice
and list::merge calls.
* testsuite/23_containers/list/operations/42352.cc: New.
2009-12-11 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/22634, DR 539 [Ready] PR libstdc++/22634, DR 539 [Ready]
* include/bits/stl_numeric.h (adjacent_difference): Use std::move * include/bits/stl_numeric.h (adjacent_difference): Use std::move
at the end of the loop body, per the Ready resolution. at the end of the loop body, per the Ready resolution.
......
...@@ -312,13 +312,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -312,13 +312,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
do do
{ {
__carry.splice(__carry.begin(), *this, begin()); __carry.splice(__carry.begin(), _GLIBCXX_MOVE(*this), begin());
for(__counter = &__tmp[0]; for(__counter = &__tmp[0];
__counter != __fill && !__counter->empty(); __counter != __fill && !__counter->empty();
++__counter) ++__counter)
{ {
__counter->merge(__carry); __counter->merge(_GLIBCXX_MOVE(__carry));
__carry.swap(*__counter); __carry.swap(*__counter);
} }
__carry.swap(*__counter); __carry.swap(*__counter);
...@@ -328,7 +328,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -328,7 +328,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
while ( !empty() ); while ( !empty() );
for (__counter = &__tmp[1]; __counter != __fill; ++__counter) for (__counter = &__tmp[1]; __counter != __fill; ++__counter)
__counter->merge(*(__counter - 1)); __counter->merge(_GLIBCXX_MOVE(*(__counter - 1)));
swap( *(__fill - 1) ); swap( *(__fill - 1) );
} }
} }
...@@ -389,13 +389,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -389,13 +389,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
do do
{ {
__carry.splice(__carry.begin(), *this, begin()); __carry.splice(__carry.begin(), _GLIBCXX_MOVE(*this), begin());
for(__counter = &__tmp[0]; for(__counter = &__tmp[0];
__counter != __fill && !__counter->empty(); __counter != __fill && !__counter->empty();
++__counter) ++__counter)
{ {
__counter->merge(__carry, __comp); __counter->merge(_GLIBCXX_MOVE(__carry), __comp);
__carry.swap(*__counter); __carry.swap(*__counter);
} }
__carry.swap(*__counter); __carry.swap(*__counter);
...@@ -405,7 +405,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -405,7 +405,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
while ( !empty() ); while ( !empty() );
for (__counter = &__tmp[1]; __counter != __fill; ++__counter) for (__counter = &__tmp[1]; __counter != __fill; ++__counter)
__counter->merge(*(__counter - 1), __comp); __counter->merge(_GLIBCXX_MOVE(*(__counter - 1)), __comp);
swap(*(__fill - 1)); swap(*(__fill - 1));
} }
} }
......
...@@ -80,8 +80,7 @@ namespace __parallel ...@@ -80,8 +80,7 @@ namespace __parallel
__gnu_parallel::sequential_tag()); } __gnu_parallel::sequential_tag()); }
// Parallel algorithm for random access iterators. // Parallel algorithm for random access iterators.
template<typename __RAIter, typename _Tp, template<typename __RAIter, typename _Tp, typename _BinaryOperation>
typename _BinaryOperation>
_Tp _Tp
__accumulate_switch(__RAIter __begin, __RAIter __end, __accumulate_switch(__RAIter __begin, __RAIter __end,
_Tp __init, _BinaryOperation __binary_op, _Tp __init, _BinaryOperation __binary_op,
...@@ -228,9 +227,8 @@ namespace __parallel ...@@ -228,9 +227,8 @@ namespace __parallel
_BinaryFunction1 __binary_op1, _BinaryFunction1 __binary_op1,
_BinaryFunction2 __binary_op2, _BinaryFunction2 __binary_op2,
_IteratorTag1, _IteratorTag2) _IteratorTag1, _IteratorTag2)
{ return inner_product(__first1, __last1, __first2, __init, { return inner_product(__first1, __last1, __first2, __init, __binary_op1,
__binary_op1, __binary_op2, __binary_op2, __gnu_parallel::sequential_tag()); }
__gnu_parallel::sequential_tag()); }
template<typename _IIter1, typename _IIter2, typename _Tp, template<typename _IIter1, typename _IIter2, typename _Tp,
typename _BinaryFunction1, typename _BinaryFunction2> typename _BinaryFunction1, typename _BinaryFunction2>
...@@ -246,9 +244,9 @@ namespace __parallel ...@@ -246,9 +244,9 @@ namespace __parallel
typedef iterator_traits<_IIter2> _TraitsType2; typedef iterator_traits<_IIter2> _TraitsType2;
typedef typename _TraitsType2::iterator_category _IteratorCategory2; typedef typename _TraitsType2::iterator_category _IteratorCategory2;
return __inner_product_switch( return __inner_product_switch(__first1, __last1, __first2, __init,
__first1, __last1, __first2, __init, __binary_op1, __binary_op1, __binary_op2,
__binary_op2, _IteratorCategory1(), _IteratorCategory2(), _IteratorCategory1(), _IteratorCategory2(),
__parallelism_tag); __parallelism_tag);
} }
...@@ -265,9 +263,10 @@ namespace __parallel ...@@ -265,9 +263,10 @@ namespace __parallel
typedef iterator_traits<_IIter2> _TraitsType2; typedef iterator_traits<_IIter2> _TraitsType2;
typedef typename _TraitsType2::iterator_category _IteratorCategory2; typedef typename _TraitsType2::iterator_category _IteratorCategory2;
return __inner_product_switch( return __inner_product_switch(__first1, __last1, __first2, __init,
__first1, __last1, __first2, __init, __binary_op1, __binary_op2, __binary_op1, __binary_op2,
_IteratorCategory1(), _IteratorCategory2()); _IteratorCategory1(),
_IteratorCategory2());
} }
template<typename _IIter1, typename _IIter2, typename _Tp> template<typename _IIter1, typename _IIter2, typename _Tp>
...@@ -341,7 +340,8 @@ namespace __parallel ...@@ -341,7 +340,8 @@ namespace __parallel
_OutputIterator _OutputIterator
__partial_sum_switch(_IIter __begin, _IIter __end, __partial_sum_switch(_IIter __begin, _IIter __end,
_OutputIterator __result, _BinaryOperation __bin_op, _OutputIterator __result, _BinaryOperation __bin_op,
random_access_iterator_tag, random_access_iterator_tag) random_access_iterator_tag,
random_access_iterator_tag)
{ {
if (_GLIBCXX_PARALLEL_CONDITION( if (_GLIBCXX_PARALLEL_CONDITION(
static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin) static_cast<__gnu_parallel::_SequenceIndex>(__end - __begin)
...@@ -393,17 +393,18 @@ namespace __parallel ...@@ -393,17 +393,18 @@ namespace __parallel
adjacent_difference(_IIter __begin, _IIter __end, adjacent_difference(_IIter __begin, _IIter __end,
_OutputIterator __result, _BinaryOperation __bin_op, _OutputIterator __result, _BinaryOperation __bin_op,
__gnu_parallel::sequential_tag) __gnu_parallel::sequential_tag)
{ return _GLIBCXX_STD_P::adjacent_difference( { return _GLIBCXX_STD_P::adjacent_difference(__begin, __end,
__begin, __end, __result, __bin_op); } __result, __bin_op); }
// Sequential fallback for input iterator case. // Sequential fallback for input iterator case.
template<typename _IIter, typename _OutputIterator, template<typename _IIter, typename _OutputIterator,
typename _BinaryOperation, typename _IteratorTag1, typename _BinaryOperation, typename _IteratorTag1,
typename _IteratorTag2> typename _IteratorTag2>
inline _OutputIterator inline _OutputIterator
__adjacent_difference_switch( __adjacent_difference_switch(_IIter __begin, _IIter __end,
_IIter __begin, _IIter __end, _OutputIterator __result, _OutputIterator __result,
_BinaryOperation __bin_op, _IteratorTag1, _IteratorTag2) _BinaryOperation __bin_op, _IteratorTag1,
_IteratorTag2)
{ return adjacent_difference(__begin, __end, __result, __bin_op, { return adjacent_difference(__begin, __end, __result, __bin_op,
__gnu_parallel::sequential_tag()); } __gnu_parallel::sequential_tag()); }
...@@ -411,11 +412,13 @@ namespace __parallel ...@@ -411,11 +412,13 @@ namespace __parallel
template<typename _IIter, typename _OutputIterator, template<typename _IIter, typename _OutputIterator,
typename _BinaryOperation> typename _BinaryOperation>
_OutputIterator _OutputIterator
__adjacent_difference_switch( __adjacent_difference_switch(_IIter __begin, _IIter __end,
_IIter __begin, _IIter __end, _OutputIterator __result, _OutputIterator __result,
_BinaryOperation __bin_op, _BinaryOperation __bin_op,
random_access_iterator_tag, random_access_iterator_tag, random_access_iterator_tag,
__gnu_parallel::_Parallelism __parallelism_tag random_access_iterator_tag,
__gnu_parallel::_Parallelism
__parallelism_tag
= __gnu_parallel::parallel_balanced) = __gnu_parallel::parallel_balanced)
{ {
if (_GLIBCXX_PARALLEL_CONDITION( if (_GLIBCXX_PARALLEL_CONDITION(
...@@ -451,8 +454,8 @@ namespace __parallel ...@@ -451,8 +454,8 @@ namespace __parallel
{ {
typedef iterator_traits<_IIter> _TraitsType; typedef iterator_traits<_IIter> _TraitsType;
typedef typename _TraitsType::value_type _ValueType; typedef typename _TraitsType::value_type _ValueType;
return adjacent_difference( return adjacent_difference(__begin, __end, __result,
__begin, __end, __result, std::minus<_ValueType>(), std::minus<_ValueType>(),
__parallelism_tag); __parallelism_tag);
} }
...@@ -480,9 +483,11 @@ namespace __parallel ...@@ -480,9 +483,11 @@ namespace __parallel
typedef iterator_traits<_OutputIterator> _OTraitsType; typedef iterator_traits<_OutputIterator> _OTraitsType;
typedef typename _OTraitsType::iterator_category _OIterCategory; typedef typename _OTraitsType::iterator_category _OIterCategory;
return __adjacent_difference_switch( return __adjacent_difference_switch(__begin, __end, __result,
__begin, __end, __result, __binary_op, __binary_op,
_IIteratorCategory(), _OIterCategory(), __parallelism_tag); _IIteratorCategory(),
_OIterCategory(),
__parallelism_tag);
} }
template<typename _IIter, typename _OutputIterator, template<typename _IIter, typename _OutputIterator,
...@@ -497,9 +502,10 @@ namespace __parallel ...@@ -497,9 +502,10 @@ namespace __parallel
typedef iterator_traits<_OutputIterator> _OTraitsType; typedef iterator_traits<_OutputIterator> _OTraitsType;
typedef typename _OTraitsType::iterator_category _OIterCategory; typedef typename _OTraitsType::iterator_category _OIterCategory;
return __adjacent_difference_switch( return __adjacent_difference_switch(__begin, __end, __result,
__begin, __end, __result, __binary_op, __binary_op,
_IIteratorCategory(), _OIterCategory()); _IIteratorCategory(),
_OIterCategory());
} }
} // end namespace } // end namespace
} // end namespace } // end namespace
......
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2009 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 Pred 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
// <http://www.gnu.org/licenses/>.
#include <list>
#include <testsuite_hooks.h>
// PR libstdc++/42352
void test01()
{
bool test __attribute__((unused)) = true;
std::list<int> l{3, 2, 4, 1, 5, 9, 0, 8, 6, 7};
l.sort();
for (auto it = l.begin(); it != l.end(); ++it)
{
static int nn = 0;
VERIFY( *it == nn++ );
}
}
void test02()
{
bool test __attribute__((unused)) = true;
std::list<int> l{3, 2, 4, 1, 5, 9, 0, 8, 6, 7};
struct compare
{
bool
operator()(int const& one, int const& two) const
{ return one > two; }
};
l.sort(compare());
for (auto it = l.begin(); it != l.end(); ++it)
{
static int nn = 9;
VERIFY( *it == nn-- );
}
}
int main()
{
test01();
test02();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment