From 76cc1b7060c843c4dc7b0fd56fa3338a658f5e22 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 25 Jun 2008 16:39:15 +0000 Subject: [PATCH] stl_algo.h (__find_if_not, [...]): Add in C++0x, per N2666. 2008-06-25 Paolo Carlini * include/bits/stl_algo.h (__find_if_not, find_if_not, all_of, any_of, none_of): Add in C++0x, per N2666. * include/bits/algorithmfwd.h: Update. * testsuite/25_algorithms/headers/algorithm/synopsis.cc: Likewise. * testsuite/25_algorithms/all_of/check_type.cc: New. * testsuite/25_algorithms/all_of/1.cc: Likewise. * testsuite/25_algorithms/all_of/requirements/explicit_instantiation/ 2.cc: Likewise. * testsuite/25_algorithms/all_of/requirements/explicit_instantiation/ pod.cc: Likewise. * testsuite/25_algorithms/any_of/check_type.cc: Likewise. * testsuite/25_algorithms/any_of/1.cc: Likewise. * testsuite/25_algorithms/any_of/requirements/explicit_instantiation/ 2.cc: Likewise. * testsuite/25_algorithms/any_of/requirements/explicit_instantiation/ pod.cc: Likewise. * testsuite/25_algorithms/none_of/check_type.cc: Likewise. * testsuite/25_algorithms/none_of/1.cc: Likewise. * testsuite/25_algorithms/none_of/requirements/explicit_instantiation/ 2.cc: Likewise. * testsuite/25_algorithms/none_of/requirements/explicit_instantiation/ pod.cc: Likewise. * testsuite/25_algorithms/find_if_not/check_type.cc: Likewise. * testsuite/25_algorithms/find_if_not/1.cc: Likewise. * testsuite/25_algorithms/find_if_not/requirements/ explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/find_if_not/requirements/ explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/copy_if/check_type.cc: Likewise. * testsuite/25_algorithms/remove_copy_if/check_type.cc: Likewise. * testsuite/25_algorithms/find_if/1.cc: Minor tweaks. From-SVN: r137118 --- libstdc++-v3/ChangeLog | 34 +++++ libstdc++-v3/include/bits/algorithmfwd.h | 20 ++- libstdc++-v3/include/bits/stl_algo.h | 136 +++++++++++++++++- .../testsuite/25_algorithms/all_of/1.cc | 71 +++++++++ .../25_algorithms/all_of/check_type.cc | 50 +++++++ .../requirements/explicit_instantiation/2.cc | 46 ++++++ .../explicit_instantiation/pod.cc | 45 ++++++ .../testsuite/25_algorithms/any_of/1.cc | 71 +++++++++ .../25_algorithms/any_of/check_type.cc | 50 +++++++ .../requirements/explicit_instantiation/2.cc | 46 ++++++ .../explicit_instantiation/pod.cc | 45 ++++++ .../25_algorithms/copy_if/check_type.cc | 60 ++++++++ .../testsuite/25_algorithms/find_if/1.cc | 21 ++- .../testsuite/25_algorithms/find_if_not/1.cc | 74 ++++++++++ .../25_algorithms/find_if_not/check_type.cc | 50 +++++++ .../requirements/explicit_instantiation/2.cc | 46 ++++++ .../explicit_instantiation/pod.cc | 45 ++++++ .../headers/algorithm/synopsis.cc | 20 ++- .../testsuite/25_algorithms/none_of/1.cc | 71 +++++++++ .../25_algorithms/none_of/check_type.cc | 50 +++++++ .../requirements/explicit_instantiation/2.cc | 46 ++++++ .../explicit_instantiation/pod.cc | 45 ++++++ .../remove_copy_if/check_type.cc | 59 ++++++++ 23 files changed, 1191 insertions(+), 10 deletions(-) create mode 100644 libstdc++-v3/testsuite/25_algorithms/all_of/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/all_of/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/any_of/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/any_of/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_if/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_if_not/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_if_not/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/none_of/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/none_of/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove_copy_if/check_type.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 0dc10f2eb2f..093c030489f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,37 @@ +2008-06-25 Paolo Carlini + + * include/bits/stl_algo.h (__find_if_not, find_if_not, all_of, + any_of, none_of): Add in C++0x, per N2666. + * include/bits/algorithmfwd.h: Update. + * testsuite/25_algorithms/headers/algorithm/synopsis.cc: Likewise. + * testsuite/25_algorithms/all_of/check_type.cc: New. + * testsuite/25_algorithms/all_of/1.cc: Likewise. + * testsuite/25_algorithms/all_of/requirements/explicit_instantiation/ + 2.cc: Likewise. + * testsuite/25_algorithms/all_of/requirements/explicit_instantiation/ + pod.cc: Likewise. + * testsuite/25_algorithms/any_of/check_type.cc: Likewise. + * testsuite/25_algorithms/any_of/1.cc: Likewise. + * testsuite/25_algorithms/any_of/requirements/explicit_instantiation/ + 2.cc: Likewise. + * testsuite/25_algorithms/any_of/requirements/explicit_instantiation/ + pod.cc: Likewise. + * testsuite/25_algorithms/none_of/check_type.cc: Likewise. + * testsuite/25_algorithms/none_of/1.cc: Likewise. + * testsuite/25_algorithms/none_of/requirements/explicit_instantiation/ + 2.cc: Likewise. + * testsuite/25_algorithms/none_of/requirements/explicit_instantiation/ + pod.cc: Likewise. + * testsuite/25_algorithms/find_if_not/check_type.cc: Likewise. + * testsuite/25_algorithms/find_if_not/1.cc: Likewise. + * testsuite/25_algorithms/find_if_not/requirements/ + explicit_instantiation/2.cc: Likewise. + * testsuite/25_algorithms/find_if_not/requirements/ + explicit_instantiation/pod.cc: Likewise. + * testsuite/25_algorithms/copy_if/check_type.cc: Likewise. + * testsuite/25_algorithms/remove_copy_if/check_type.cc: Likewise. + * testsuite/25_algorithms/find_if/1.cc: Minor tweaks. + 2008-06-24 Benjamin Kosnik * doc/xml/manual/parallel_mode.xml: Clarify use of explicit diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h index b4d2ee795ea..992dc4f5afe 100644 --- a/libstdc++-v3/include/bits/algorithmfwd.h +++ b/libstdc++-v3/include/bits/algorithmfwd.h @@ -169,6 +169,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // generate // generate_n +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template + bool + all_of(_IIter, _IIter, _Predicate); + + template + bool + any_of(_IIter, _IIter, _Predicate); + + template + bool + none_of(_IIter, _IIter, _Predicate); + + template + _IIter + find_if_not(_IIter, _IIter, _Predicate); +#endif + template bool includes(_IIter1, _IIter1, _IIter2, _IIter2); @@ -461,7 +479,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P) find_first_of(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); template - _IIter + _IIter find_if(_IIter, _IIter, _Predicate); template diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 6b1e8a52bd0..cee7d613d6a 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -260,6 +260,67 @@ _GLIBCXX_BEGIN_NAMESPACE(std) } } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /// This is an overload used by find_if_not() for the Input Iterator case. + template + inline _InputIterator + __find_if_not(_InputIterator __first, _InputIterator __last, + _Predicate __pred, input_iterator_tag) + { + while (__first != __last && bool(__pred(*__first))) + ++__first; + return __first; + } + + /// This is an overload used by find_if_not() for the RAI case. + template + _RandomAccessIterator + __find_if_not(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Predicate __pred, random_access_iterator_tag) + { + typename iterator_traits<_RandomAccessIterator>::difference_type + __trip_count = (__last - __first) >> 2; + + for (; __trip_count > 0; --__trip_count) + { + if (!bool(__pred(*__first))) + return __first; + ++__first; + + if (!bool(__pred(*__first))) + return __first; + ++__first; + + if (!bool(__pred(*__first))) + return __first; + ++__first; + + if (!bool(__pred(*__first))) + return __first; + ++__first; + } + + switch (__last - __first) + { + case 3: + if (!bool(__pred(*__first))) + return __first; + ++__first; + case 2: + if (!bool(__pred(*__first))) + return __first; + ++__first; + case 1: + if (!bool(__pred(*__first))) + return __first; + ++__first; + case 0: + default: + return __last; + } + } +#endif + // set_difference // set_intersection // set_symmetric_difference @@ -667,6 +728,79 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __comp); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Checks that a predicate is true for all the elements + * of a sequence. + * @param first An input iterator. + * @param last An input iterator. + * @param pred A predicate. + * @return True if the check is true, false otherwise. + * + * Returns true if @p pred is true for each element in the range + * @p [first,last), and false otherwise. + */ + template + inline bool + all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) + { return __last == std::find_if_not(__first, __last, __pred); } + + /** + * @brief Checks that a predicate is false for all the elements + * of a sequence. + * @param first An input iterator. + * @param last An input iterator. + * @param pred A predicate. + * @return True if the check is true, false otherwise. + * + * Returns true if @p pred is false for each element in the range + * @p [first,last), and false otherwise. + */ + template + inline bool + none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) + { return __last == _GLIBCXX_STD_P::find_if(__first, __last, __pred); } + + /** + * @brief Checks that a predicate is false for at least an element + * of a sequence. + * @param first An input iterator. + * @param last An input iterator. + * @param pred A predicate. + * @return True if the check is true, false otherwise. + * + * Returns true if an element exists in the range @p [first,last) such that + * @p pred is true, and false otherwise. + */ + template + inline bool + any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) + { return !std::none_of(__first, __last, __pred); } + + /** + * @brief Find the first element in a sequence for which a + * predicate is false. + * @param first An input iterator. + * @param last An input iterator. + * @param pred A predicate. + * @return The first iterator @c i in the range @p [first,last) + * such that @p pred(*i) is false, or @p last if no such iterator exists. + */ + template + inline _InputIterator + find_if_not(_InputIterator __first, _InputIterator __last, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + return std::__find_if_not(__first, __last, __pred, + std::__iterator_category(__first)); + } +#endif + /** * @brief Copy a sequence, removing elements of a given value. @@ -1171,7 +1305,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template _OutputIterator reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, - _OutputIterator __result) + _OutputIterator __result) { // concept requirements __glibcxx_function_requires(_BidirectionalIteratorConcept< diff --git a/libstdc++-v3/testsuite/25_algorithms/all_of/1.cc b/libstdc++-v3/testsuite/25_algorithms/all_of/1.cc new file mode 100644 index 00000000000..819aa44edd5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/all_of/1.cc @@ -0,0 +1,71 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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. + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 0; } + +void +test1() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array); + VERIFY( std::all_of(con.begin(), con.end(), predicate) ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 1); + VERIFY( std::all_of(con.begin(), con.end(), predicate) ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 6); + VERIFY( !std::all_of(con.begin(), con.end(), predicate) ); +} + +int +main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/all_of/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/all_of/check_type.cc new file mode 100644 index 00000000000..bf2191e1c04 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/all_of/check_type.cc @@ -0,0 +1,50 @@ +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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. + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include +#include + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +bool +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::all_of(begin, end, pred_function); } + +bool +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::all_of(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/2.cc new file mode 100644 index 00000000000..323fb6a25ba --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/2.cc @@ -0,0 +1,46 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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 +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template bool all_of(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/pod.cc new file mode 100644 index 00000000000..547e2d3808e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,45 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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 +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template bool all_of(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/any_of/1.cc b/libstdc++-v3/testsuite/25_algorithms/any_of/1.cc new file mode 100644 index 00000000000..68d2ee77fff --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/any_of/1.cc @@ -0,0 +1,71 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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. + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 1; } + +void +test1() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array); + VERIFY( !std::any_of(con.begin(), con.end(), predicate) ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 1); + VERIFY( !std::any_of(con.begin(), con.end(), predicate) ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 6); + VERIFY( std::any_of(con.begin(), con.end(), predicate) ); +} + +int +main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/any_of/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/any_of/check_type.cc new file mode 100644 index 00000000000..6b337f2a1e3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/any_of/check_type.cc @@ -0,0 +1,50 @@ +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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. + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include +#include + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +bool +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::any_of(begin, end, pred_function); } + +bool +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::any_of(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/2.cc new file mode 100644 index 00000000000..417becf440e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/2.cc @@ -0,0 +1,46 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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 +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template bool any_of(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/pod.cc new file mode 100644 index 00000000000..37aa1540043 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,45 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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 +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template bool any_of(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/copy_if/check_type.cc new file mode 100644 index 00000000000..c50649d09be --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_if/check_type.cc @@ -0,0 +1,60 @@ +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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. + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include +#include + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct X { }; + +struct Z +{ + Z& + operator=(const X&) + { return *this; } +}; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +output_iterator_wrapper +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end, + output_iterator_wrapper& output) +{ return std::copy_if(begin, end, output, pred_function); } + +output_iterator_wrapper +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end, + output_iterator_wrapper& output) +{ return std::copy_if(begin, end, output, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/find_if/1.cc index a14cb694ca7..dae925a120d 100644 --- a/libstdc++-v3/testsuite/25_algorithms/find_if/1.cc +++ b/libstdc++-v3/testsuite/25_algorithms/find_if/1.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2005 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007, 2008 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 @@ -35,25 +35,31 @@ predicate(const int& i) void test1() { + bool test __attribute__((unused)) = true; + Container con(array, array); - VERIFY(std::find_if(con.begin(), con.end(), - predicate).ptr == array); + VERIFY( std::find_if(con.begin(), con.end(), + predicate).ptr == array ); } void test2() { + bool test __attribute__((unused)) = true; + Container con(array, array + 1); - VERIFY(std::find_if(con.begin(), con.end(), - predicate).ptr == array + 1); + VERIFY( std::find_if(con.begin(), con.end(), + predicate).ptr == array + 1 ); } void test3() { + bool test __attribute__((unused)) = true; + Container con(array, array + 6); - VERIFY(std::find_if(con.begin(), con.end(), - predicate).ptr == array + 3); + VERIFY( std::find_if(con.begin(), con.end(), + predicate).ptr == array + 3 ); } int @@ -62,4 +68,5 @@ main() test1(); test2(); test3(); + return 0; } diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if_not/1.cc b/libstdc++-v3/testsuite/25_algorithms/find_if_not/1.cc new file mode 100644 index 00000000000..e16e8088231 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if_not/1.cc @@ -0,0 +1,74 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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. + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 0; } + +void +test1() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array); + VERIFY( std::find_if_not(con.begin(), con.end(), + predicate).ptr == array ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 1); + VERIFY( std::find_if_not(con.begin(), con.end(), + predicate).ptr == array + 1 ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 6); + VERIFY( std::find_if_not(con.begin(), con.end(), + predicate).ptr == array + 3 ); +} + +int +main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if_not/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/find_if_not/check_type.cc new file mode 100644 index 00000000000..6f445eb3261 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if_not/check_type.cc @@ -0,0 +1,50 @@ +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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. + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include +#include + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +input_iterator_wrapper +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::find_if_not(begin, end, pred_function); } + +input_iterator_wrapper +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::find_if_not(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/2.cc new file mode 100644 index 00000000000..b348dd0561a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/2.cc @@ -0,0 +1,46 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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 +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type find_if_not(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/pod.cc new file mode 100644 index 00000000000..f1854b880f9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,45 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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 +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type find_if_not(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc index 87487b3d8e6..8bfb22b4f60 100644 --- a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc +++ b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc @@ -32,9 +32,27 @@ namespace std find(_IIter, _IIter, const _Tp&); template - _IIter + _IIter find_if(_IIter, _IIter, _Predicate); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template + bool + all_of(_IIter, _IIter, _Predicate); + + template + bool + any_of(_IIter, _IIter, _Predicate); + + template + bool + none_of(_IIter, _IIter, _Predicate); + + template + _IIter + find_if_not(_IIter, _IIter, _Predicate); +#endif + template _FIter1 find_end(_FIter1, _FIter1, _FIter2, _FIter2); diff --git a/libstdc++-v3/testsuite/25_algorithms/none_of/1.cc b/libstdc++-v3/testsuite/25_algorithms/none_of/1.cc new file mode 100644 index 00000000000..bc4ec0aa1f9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/none_of/1.cc @@ -0,0 +1,71 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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. + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 1; } + +void +test1() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array); + VERIFY( std::none_of(con.begin(), con.end(), predicate) ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 1); + VERIFY( std::none_of(con.begin(), con.end(), predicate) ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 6); + VERIFY( !std::none_of(con.begin(), con.end(), predicate) ); +} + +int +main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/none_of/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/none_of/check_type.cc new file mode 100644 index 00000000000..2b71f995a18 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/none_of/check_type.cc @@ -0,0 +1,50 @@ +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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. + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include +#include + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +bool +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::none_of(begin, end, pred_function); } + +bool +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::none_of(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/2.cc new file mode 100644 index 00000000000..8fb36fd82b0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/2.cc @@ -0,0 +1,46 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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 +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template bool none_of(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/pod.cc new file mode 100644 index 00000000000..da7e18aaa14 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,45 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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 +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template bool none_of(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/check_type.cc new file mode 100644 index 00000000000..cea646ddbc2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/check_type.cc @@ -0,0 +1,59 @@ +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008 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. + +// { dg-do compile } + +#include +#include + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct X { }; + +struct Z +{ + Z& + operator=(const X&) + { return *this; } +}; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +output_iterator_wrapper +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end, + output_iterator_wrapper& output) +{ return std::remove_copy_if(begin, end, output, pred_function); } + +output_iterator_wrapper +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end, + output_iterator_wrapper& output) +{ return std::remove_copy_if(begin, end, output, pred_obj()); }