[multiple changes]

2009-10-05  Paolo Carlini  <paolo.carlini@oracle.com>

	* testsuite/lib/libstdc++.exp (check_v3_target_rvalref): Remove.
	* testsuite/lib/dg-options.exp (dg-require-rvalref): Likewise.

2009-10-05  Chris Jefferson  <chris@bubblescope.net>

	* include/bits/stl_algo.h (__stable_partition_adaptive,
	__rotate_adaptive, __merge_adaptive, __merge_sort_loop):
	Extend to work with rvalue references in C++0x mode.
	* testsuite/25_algorithms/inplace_merge/moveable2.cc: New.
	* testsuite/25_algorithms/inplace_merge/moveable.cc: Likewise.
	* testsuite/25_algorithms/stable_partition/moveable.cc: Likewise.
	* testsuite/25_algorithms/stable_sort/moveable2.cc: Likewise.
	* testsuite/25_algorithms/stable_sort/moveable.cc: Likewise.

From-SVN: r152451
This commit is contained in:
Paolo Carlini 2009-10-05 14:11:11 +00:00
parent 1a735925e3
commit fe03b3df84
9 changed files with 365 additions and 95 deletions

View File

@ -1,3 +1,19 @@
2009-10-05 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/lib/libstdc++.exp (check_v3_target_rvalref): Remove.
* testsuite/lib/dg-options.exp (dg-require-rvalref): Likewise.
2009-10-05 Chris Jefferson <chris@bubblescope.net>
* include/bits/stl_algo.h (__stable_partition_adaptive,
__rotate_adaptive, __merge_adaptive, __merge_sort_loop):
Extend to work with rvalue references in C++0x mode.
* testsuite/25_algorithms/inplace_merge/moveable2.cc: New.
* testsuite/25_algorithms/inplace_merge/moveable.cc: Likewise.
* testsuite/25_algorithms/stable_partition/moveable.cc: Likewise.
* testsuite/25_algorithms/stable_sort/moveable2.cc: Likewise.
* testsuite/25_algorithms/stable_sort/moveable.cc: Likewise.
2009-10-04 Benjamin Kosnik <bkoz@redhat.com>
* doc/xml/manual/using.xml: Add profile headers.

View File

@ -1862,15 +1862,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
for (; __first != __last; ++__first)
if (__pred(*__first))
{
*__result1 = *__first;
*__result1 = _GLIBCXX_MOVE(*__first);
++__result1;
}
else
{
*__result2 = *__first;
*__result2 = _GLIBCXX_MOVE(*__first);
++__result2;
}
std::copy(__buffer, __result2, __result1);
_GLIBCXX_MOVE3(__buffer, __result2, __result1);
return __result1;
}
else
@ -2926,15 +2926,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_BidirectionalIterator2 __buffer_end;
if (__len1 > __len2 && __len2 <= __buffer_size)
{
__buffer_end = std::copy(__middle, __last, __buffer);
std::copy_backward(__first, __middle, __last);
return std::copy(__buffer, __buffer_end, __first);
__buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer);
_GLIBCXX_MOVE_BACKWARD3(__first, __middle, __last);
return _GLIBCXX_MOVE3(__buffer, __buffer_end, __first);
}
else if (__len1 <= __buffer_size)
{
__buffer_end = std::copy(__first, __middle, __buffer);
std::copy(__middle, __last, __first);
return std::copy_backward(__buffer, __buffer_end, __last);
__buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer);
_GLIBCXX_MOVE3(__middle, __last, __first);
return _GLIBCXX_MOVE_BACKWARD3(__buffer, __buffer_end, __last);
}
else
{
@ -2956,15 +2956,21 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
if (__len1 <= __len2 && __len1 <= __buffer_size)
{
_Pointer __buffer_end = std::copy(__first, __middle, __buffer);
_GLIBCXX_STD_P::merge(__buffer, __buffer_end, __middle, __last,
_Pointer __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer);
_GLIBCXX_STD_P::merge(_GLIBCXX_MAKE_MOVE_ITERATOR(__buffer),
_GLIBCXX_MAKE_MOVE_ITERATOR(__buffer_end),
_GLIBCXX_MAKE_MOVE_ITERATOR(__middle),
_GLIBCXX_MAKE_MOVE_ITERATOR(__last),
__first);
}
else if (__len2 <= __buffer_size)
{
_Pointer __buffer_end = std::copy(__middle, __last, __buffer);
std::__merge_backward(__first, __middle, __buffer,
__buffer_end, __last);
_Pointer __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer);
std::__merge_backward(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
_GLIBCXX_MAKE_MOVE_ITERATOR(__middle),
_GLIBCXX_MAKE_MOVE_ITERATOR(__buffer),
_GLIBCXX_MAKE_MOVE_ITERATOR(__buffer_end),
__last);
}
else
{
@ -3013,15 +3019,21 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
if (__len1 <= __len2 && __len1 <= __buffer_size)
{
_Pointer __buffer_end = std::copy(__first, __middle, __buffer);
_GLIBCXX_STD_P::merge(__buffer, __buffer_end, __middle, __last,
_Pointer __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer);
_GLIBCXX_STD_P::merge(_GLIBCXX_MAKE_MOVE_ITERATOR(__buffer),
_GLIBCXX_MAKE_MOVE_ITERATOR(__buffer_end),
_GLIBCXX_MAKE_MOVE_ITERATOR(__middle),
_GLIBCXX_MAKE_MOVE_ITERATOR(__last),
__first, __comp);
}
else if (__len2 <= __buffer_size)
{
_Pointer __buffer_end = std::copy(__middle, __last, __buffer);
std::__merge_backward(__first, __middle, __buffer, __buffer_end,
__last, __comp);
_Pointer __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer);
std::__merge_backward(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
_GLIBCXX_MAKE_MOVE_ITERATOR(__middle),
_GLIBCXX_MAKE_MOVE_ITERATOR(__buffer),
_GLIBCXX_MAKE_MOVE_ITERATOR(__buffer_end),
__last,__comp);
}
else
{
@ -3270,16 +3282,22 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
while (__last - __first >= __two_step)
{
__result = _GLIBCXX_STD_P::merge(__first, __first + __step_size,
__first + __step_size,
__first + __two_step,
__result);
__result = _GLIBCXX_STD_P::merge(
_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
_GLIBCXX_MAKE_MOVE_ITERATOR(__first + __step_size),
_GLIBCXX_MAKE_MOVE_ITERATOR(__first + __step_size),
_GLIBCXX_MAKE_MOVE_ITERATOR(__first + __two_step),
__result);
__first += __two_step;
}
__step_size = std::min(_Distance(__last - __first), __step_size);
_GLIBCXX_STD_P::merge(__first, __first + __step_size,
__first + __step_size, __last,
_GLIBCXX_STD_P::merge(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
_GLIBCXX_MAKE_MOVE_ITERATOR(__first +
__step_size),
_GLIBCXX_MAKE_MOVE_ITERATOR(__first +
__step_size),
_GLIBCXX_MAKE_MOVE_ITERATOR(__last),
__result);
}
@ -3295,16 +3313,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
while (__last - __first >= __two_step)
{
__result = _GLIBCXX_STD_P::merge(__first, __first + __step_size,
__first + __step_size, __first + __two_step,
__result,
__comp);
__result = _GLIBCXX_STD_P::merge(
_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
_GLIBCXX_MAKE_MOVE_ITERATOR(__first + __step_size),
_GLIBCXX_MAKE_MOVE_ITERATOR(__first + __step_size),
_GLIBCXX_MAKE_MOVE_ITERATOR(__first + __two_step),
__result, __comp);
__first += __two_step;
}
__step_size = std::min(_Distance(__last - __first), __step_size);
_GLIBCXX_STD_P::merge(__first, __first + __step_size,
__first + __step_size, __last, __result, __comp);
_GLIBCXX_STD_P::merge(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
_GLIBCXX_MAKE_MOVE_ITERATOR(__first +
__step_size),
_GLIBCXX_MAKE_MOVE_ITERATOR(__first +
__step_size),
_GLIBCXX_MAKE_MOVE_ITERATOR(__last),
__result, __comp);
}
template<typename _RandomAccessIterator, typename _Distance>

View File

@ -0,0 +1,52 @@
// { 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 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
// <http://www.gnu.org/licenses/>.
// 25.3.4 [lib.alg.merge]
#include <algorithm>
#include <testsuite_hooks.h>
#include <testsuite_iterators.h>
#include <testsuite_rvalref.h>
using __gnu_test::test_container;
using __gnu_test::bidirectional_iterator_wrapper;
using __gnu_test::rvalstruct;
typedef test_container<rvalstruct, bidirectional_iterator_wrapper> container;
void
test01()
{
bool test __attribute__((unused)) = true;
int array[]={0,2,4,1,3,5};
rvalstruct rv_array[6];
std::copy(array, array + 6, rv_array);
container con(rv_array, rv_array + 6);
std::inplace_merge(con.begin(), con.it(3), con.end());
VERIFY( rv_array[0] == 0 && rv_array[1] == 1 && rv_array[2] == 2
&& rv_array[3] == 3 && rv_array[4] == 4 && rv_array[5] == 5 );
}
int
main()
{
test01();
return 0;
}

View File

@ -0,0 +1,56 @@
// { 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 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
// <http://www.gnu.org/licenses/>.
// 25.3.4 [lib.alg.merge]
#include <algorithm>
#include <testsuite_hooks.h>
#include <testsuite_iterators.h>
#include <testsuite_rvalref.h>
using __gnu_test::test_container;
using __gnu_test::bidirectional_iterator_wrapper;
using __gnu_test::rvalstruct;
typedef test_container<rvalstruct, bidirectional_iterator_wrapper> container;
bool
are_ordered(const rvalstruct& lhs, const rvalstruct& rhs)
{ return lhs < rhs; }
void
test01()
{
bool test __attribute__((unused)) = true;
int array[]={0,2,4,1,3,5};
rvalstruct rv_array[6];
std::copy(array, array + 6, rv_array);
container con(rv_array, rv_array + 6);
std::inplace_merge(con.begin(), con.it(3), con.end(), are_ordered);
VERIFY( rv_array[0] == 0 && rv_array[1] == 1 && rv_array[2] == 2
&& rv_array[3] == 3 && rv_array[4] == 4 && rv_array[5] == 5 );
}
int
main()
{
test01();
return 0;
}

View File

@ -0,0 +1,64 @@
// { 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/>.
// 25.2.12 [lib.alg.partitions] Partitions.
#include <algorithm>
#include <functional>
#include <testsuite_hooks.h>
#include <testsuite_iterators.h>
#include <testsuite_rvalref.h>
using __gnu_test::test_container;
using __gnu_test::random_access_iterator_wrapper;
using __gnu_test::rvalstruct;
typedef test_container<rvalstruct, random_access_iterator_wrapper> Container;
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
const int B[] = {2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15, 17};
const int N = sizeof(A) / sizeof(int);
struct Pred
{
bool
operator()(const rvalstruct& x) const
{ return (x.val % 2) == 0; }
};
// 25.2.12 stable_partition()
void
test01()
{
bool test __attribute__((unused)) = true;
rvalstruct s1[N];
std::copy(A, A + N, s1);
Container con(s1, s1 + N);
std::stable_partition(con.begin(), con.end(), Pred());
VERIFY( std::equal(s1, s1 + N, B) );
}
int
main()
{
test01();
return 0;
}

View File

@ -0,0 +1,59 @@
// { 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 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
// <http://www.gnu.org/licenses/>.
// 25.3.1.2 [lib.stable.sort]
#undef _GLIBCXX_CONCEPT_CHECKS
#include <algorithm>
#include <testsuite_hooks.h>
#include <testsuite_iterators.h>
#include <testsuite_rvalref.h>
using __gnu_test::test_container;
using __gnu_test::random_access_iterator_wrapper;
using __gnu_test::rvalstruct;
typedef test_container<rvalstruct, random_access_iterator_wrapper> Container;
const int A[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7,
17, 8, 18, 9, 19 };
const int N = sizeof(A) / sizeof(int);
// 25.3.1.2 stable_sort()
void
test01()
{
bool test __attribute__((unused)) = true;
rvalstruct s1[N];
std::copy(A, A + N, s1);
Container con(s1, s1 + N);
std::stable_sort(con.begin(), con.end());
VERIFY( s1[0].valid );
for(int i = 1; i < N; ++i)
VERIFY( s1[i].val>s1[i-1].val && s1[i].valid );
}
int
main()
{
test01();
return 0;
}

View File

@ -0,0 +1,62 @@
// { 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 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
// <http://www.gnu.org/licenses/>.
// 25.3.1.2 [lib.stable.sort]
#undef _GLIBCXX_CONCEPT_CHECKS
#include <algorithm>
#include <testsuite_hooks.h>
#include <testsuite_iterators.h>
#include <testsuite_rvalref.h>
using __gnu_test::test_container;
using __gnu_test::random_access_iterator_wrapper;
using __gnu_test::rvalstruct;
typedef test_container<rvalstruct, random_access_iterator_wrapper> Container;
const int A[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7,
17, 8, 18, 9, 19 };
const int N = sizeof(A) / sizeof(int);
bool order(const rvalstruct& lhs, const rvalstruct& rhs)
{ return lhs < rhs; }
// 25.3.1.2 stable_sort()
void
test01()
{
bool test __attribute__((unused)) = true;
rvalstruct s1[N];
std::copy(A, A + N, s1);
Container con(s1, s1 + N);
std::stable_sort(con.begin(), con.end(), order);
VERIFY( s1[0].valid );
for(int i = 1; i < N; ++i)
VERIFY( s1[i].val>s1[i-1].val && s1[i].valid );
}
int
main()
{
test01();
return 0;
}

View File

@ -80,15 +80,6 @@ proc dg-require-time { args } {
return
}
proc dg-require-rvalref { args } {
if { ![ check_v3_target_rvalref ] } {
upvar dg-do-what dg-do-what
set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
return
}
return
}
proc dg-require-cstdint { args } {
if { ![ check_v3_target_cstdint ] } {
upvar dg-do-what dg-do-what

View File

@ -805,61 +805,6 @@ proc check_v3_target_time { } {
return $et_time_saved
}
proc check_v3_target_rvalref { } {
global et_rvalref_saved
global et_rvalref_target_name
global tool
if { ![info exists et_rvalref_target_name] } {
set et_rvalref_target_name ""
}
# If the target has changed since we set the cached value, clear it.
set current_target [current_target_name]
if { $current_target != $et_rvalref_target_name } {
verbose "check_v3_target_rvalref: `$et_rvalref_target_name'" 2
set et_rvalref_target_name $current_target
if [info exists et_rvalref_saved] {
verbose "check_v3_target_rvalref: removing cached result" 2
unset et_rvalref_saved
}
}
if [info exists et_rvalref_saved] {
verbose "check_v3_target_rvalref: using cached result" 2
} else {
set et_rvalref_saved 0
# Set up and compile a C++ test program that tries to use
# the library components of rval references
set src rvalref[pid].cc
set exe rvalref[pid].x
set f [open $src "w"]
puts $f "#include <iterator>"
puts $f "#include <utility>"
puts $f "using std::move;"
puts $f "using std::identity;"
puts $f "using std::forward;"
puts $f "using std::move_iterator;"
puts $f "using std::make_move_iterator;"
close $f
set lines [v3_target_compile $src $exe executable ""]
file delete $src
if [string match "" $lines] {
# No error message, compilation succeeded.
verbose "check_v3_target_rvalref: compilation succeeded" 2
remote_file build delete $exe
set et_rvalref_saved 1
} else {
verbose "check_v3_target_rvalref: compilation failed" 2
}
}
return $et_rvalref_saved
}
proc check_v3_target_namedlocale { } {
global et_namedlocale_saved
global et_namedlocale_target_name