diff options
author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-10-03 17:27:18 +0000 |
---|---|---|
committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-10-03 17:27:18 +0000 |
commit | 5348e86a46b129b304326f3db600aaaae9c62ee9 (patch) | |
tree | 46cc3fffe09f0d59f370c379911fdc297f83f02b /libstdc++-v3/testsuite/25_algorithms/remove_if | |
parent | 9c78c8fe7549b840655bf32cb19695d53eb83b63 (diff) | |
download | gcc-5348e86a46b129b304326f3db600aaaae9c62ee9.tar.gz |
2007-10-03 Chris Jefferson <chris@bubblescope.net>
Benjamin Kosnik <bkoz@redhat.com>
* testsuite/20_util/pair/moveable.cc: New. Merge from
libstdcxx_so_7-branch.
* testsuite/23_containers/deque/capacity/moveable.cc: Same.
* testsuite/23_containers/deque/cons/moveable.cc: Same.
* testsuite/23_containers/deque/modifiers/moveable.cc: Same.
* testsuite/23_containers/deque/moveable.cc: Same.
* testsuite/23_containers/list/moveable.cc: Same.
* testsuite/23_containers/map/moveable.cc: Same.
* testsuite/23_containers/multimap/moveable.cc: Same.
* testsuite/23_containers/multiset/moveable.cc: Same.
* testsuite/23_containers/set/moveable.cc: Same.
* testsuite/23_containers/vector/cons/moveable.cc: Same.
* testsuite/23_containers/vector/modifiers/moveable.cc: Same.
* testsuite/23_containers/vector/moveable.cc: Same.
* testsuite/23_containers/vector/resize/moveable.cc: Same.
* testsuite/25_algorithms/heap/moveable.cc: Same.
* testsuite/25_algorithms/nth_element/moveable.cc: Same.
* testsuite/25_algorithms/partial_sort/moveable.cc: Same.
* testsuite/25_algorithms/partition/moveable.cc: Same.
* testsuite/25_algorithms/remove_if/moveable.cc: Same.
* testsuite/25_algorithms/remove/moveable.cc: Same.
* testsuite/25_algorithms/reverse/moveable.cc: Same.
* testsuite/25_algorithms/rotate/moveable.cc: Same.
* testsuite/25_algorithms/sort/moveable.cc: Same.
* testsuite/25_algorithms/swap_ranges/moveable.cc: Same.
* testsuite/25_algorithms/unique/moveable.cc: Same.
* testsuite/util/testsuite_rvalref.h: New.
* testsuite/25_algorithms/equal/equal.cc: Move to...
* testsuite/25_algorithms/equal/no_operator_ne.cc: ...this.
* testsuite/25_algorithms/heap/heap.cc: Move to...
* testsuite/25_algorithms/heap/1.cc: ...this.
* testsuite/25_algorithms/lower_bound/lower_bound.cc: Move to...
* testsuite/25_algorithms/lower_bound/no_operator_ne.cc: ...this.
* testsuite/25_algorithms/partition/partition.cc: Move to...
* testsuite/25_algorithms/partition/1.cc: ...this.
* testsuite/25_algorithms/stable_partition/1.cc: ... and this.
* testsuite/25_algorithms/search/1.cc: Update from merge.
* testsuite/25_algorithms/search/check_type.cc: Same.
* testsuite/lib/dg-options.exp (dg-require-rvalref): New.
* testsuite/lib/libstdc++.exp (check_v3_target_rvalref): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128990 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/25_algorithms/remove_if')
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/remove_if/moveable.cc | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_if/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/remove_if/moveable.cc new file mode 100644 index 00000000000..15b9ab679d8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_if/moveable.cc @@ -0,0 +1,68 @@ +// { dg-require-rvalref "" } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 remove + +#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::forward_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container<rvalstruct, forward_iterator_wrapper> Container; + +bool equal1(rvalstruct& in) { return in.val == 1; } +bool equal0(rvalstruct& in) { return in.val == 0; } + +void +test1() +{ + int intarray[] = {1}; + rvalstruct array[1]; + std::copy(intarray, intarray + 1, array); + Container con(array, array + 1); + VERIFY(std::remove_if(con.begin(), con.end(), equal0).ptr == array + 1); + VERIFY(std::remove_if(con.begin(), con.end(), equal1).ptr == array); +} + +void +test2() +{ + int intarray[] = {0, 1, 0, 1, 0, 0, 1, 1}; + rvalstruct array[8]; + std::copy(intarray, intarray + 8, array); + Container con(array, array + 8); + VERIFY(std::remove_if(con.begin(), con.end(), equal1).ptr == array + 4); + VERIFY(array[0] == 0 && array[1] == 0 && array[2] == 0 && + array[3] == 0); +} + +int +main() +{ + test1(); + test2(); +} |