diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-10-14 21:17:23 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-10-14 21:17:23 +0000 |
commit | f9cdaf4bd093f2284cf785c9c718b93c0548b249 (patch) | |
tree | 8fde0a4c243d36b17d1790b5131fc7591488d023 /libstdc++-v3/testsuite/25_algorithms | |
parent | 366f17edd85893ad1057933b226660f95f18a878 (diff) | |
download | ppe42-gcc-f9cdaf4bd093f2284cf785c9c718b93c0548b249.tar.gz ppe42-gcc-f9cdaf4bd093f2284cf785c9c718b93c0548b249.zip |
2007-10-14 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_algo.h (is_sorted, is_sorted_until): Add.
* include/bits/algorithmfwd.h: Add.
* include/ext/algorithm: Adjust.
* testsuite/25_algorithms/is_sorted/requirements/
explicit_instantiation/2.cc: New.
* testsuite/25_algorithms/is_sorted/requirements/
explicit_instantiation/pod.cc: Likewise.
* testsuite/25_algorithms/is_sorted/1.cc: Likewise.
* testsuite/25_algorithms/is_sorted_until/requirements/
explicit_instantiation/2.cc: Likewise.
* testsuite/25_algorithms/is_sorted_until/requirements/
explicit_instantiation/pod.cc: Likewise.
* testsuite/25_algorithms/is_sorted_until/1.cc: Likewise.
* testsuite/25_algorithms/headers/algorithm/synopsis.cc:
Add is_sorted and is_sorted_until.
* include/bits/stl_heap.h (is_heap_until): Add concept and
debug-mode checks.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129303 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/25_algorithms')
7 files changed, 308 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc index 3176a53d4e6..7a02610a320 100644 --- a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc +++ b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc @@ -417,6 +417,22 @@ namespace std template<typename _RAIter, typename _Compare> _RAIter is_heap_until(_RAIter, _RAIter, _Compare); + + template<typename _FIter> + bool + is_sorted(_FIter, _FIter); + + template<typename _FIter, typename _Compare> + bool + is_sorted(_FIter, _FIter, _Compare); + + template<typename _FIter> + _FIter + is_sorted_until(_FIter, _FIter); + + template<typename _FIter, typename _Compare> + _FIter + is_sorted_until(_FIter, _FIter, _Compare); #endif // 25.3.7, minimum and maximum: diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted/1.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted/1.cc new file mode 100644 index 00000000000..840597ba318 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted/1.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-14 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 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 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 25.3.6 Heap operations [lib.alg.heap.operations] + +#include <algorithm> +#include <functional> +#include <testsuite_hooks.h> + +int A[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; +int B[] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; +const int N = sizeof(A) / sizeof(int); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + for (int i = 0; i <= N; ++i) + { + VERIFY( std::is_sorted(A, A + i) ); + VERIFY( std::is_sorted(A, A + i, std::less<int>()) ); + VERIFY( std::is_sorted(B, B + i, std::greater<int>()) ); + VERIFY( (i < 2) || !std::is_sorted(B, B + i) ); + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted/requirements/explicit_instantiation/2.cc new file mode 100644 index 00000000000..40052015db5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted/requirements/explicit_instantiation/2.cc @@ -0,0 +1,47 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-14 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include <algorithm> +#include <functional> +#include <testsuite_api.h> + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less<value_type> compare_type; + + template bool is_sorted(iterator_type, iterator_type); + template bool is_sorted(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted/requirements/explicit_instantiation/pod.cc new file mode 100644 index 00000000000..9a2e5560790 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,46 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-14 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include <algorithm> +#include <testsuite_character.h> + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less<value_type> compare_type; + + template bool is_sorted(iterator_type, iterator_type); + template bool is_sorted(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/1.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/1.cc new file mode 100644 index 00000000000..7be31eedecd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/1.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-14 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 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 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 25.3.6 Heap operations [lib.alg.heap.operations] + +#include <algorithm> +#include <functional> +#include <testsuite_hooks.h> + +int A[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; +int B[] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; +const int N = sizeof(A) / sizeof(int); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + for (int i = 0; i <= N; ++i) + { + VERIFY( A + i == std::is_sorted_until(A, A + i) ); + VERIFY( A + i == std::is_sorted_until(A, A + i, std::less<int>()) ); + VERIFY( B + i == std::is_sorted_until(B, B + i, std::greater<int>()) ); + VERIFY( B + (i < 2 ? i : 1) == std::is_sorted_until(B, B + i) ); + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/requirements/explicit_instantiation/2.cc new file mode 100644 index 00000000000..f13f7b008b0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/requirements/explicit_instantiation/2.cc @@ -0,0 +1,48 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-14 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include <algorithm> +#include <functional> +#include <testsuite_api.h> + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less<value_type> compare_type; + + template iterator_type is_sorted_until(iterator_type, iterator_type); + template iterator_type is_sorted_until(iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/requirements/explicit_instantiation/pod.cc new file mode 100644 index 00000000000..d6a473f34fc --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,47 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-14 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include <algorithm> +#include <testsuite_character.h> + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less<value_type> compare_type; + + template iterator_type is_sorted_until(iterator_type, iterator_type); + template iterator_type is_sorted_until(iterator_type, iterator_type, + compare_type); +} |