stl_algo.h (__find_if_not, [...]): Add in C++0x, per N2666.
2008-06-25 Paolo Carlini <paolo.carlini@oracle.com> * 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
This commit is contained in:
parent
0ee6106531
commit
76cc1b7060
@ -1,3 +1,37 @@
|
||||
2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* 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 <bkoz@redhat.com>
|
||||
|
||||
* doc/xml/manual/parallel_mode.xml: Clarify use of explicit
|
||||
|
@ -169,6 +169,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
// generate
|
||||
// generate_n
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
template<typename _IIter, typename _Predicate>
|
||||
bool
|
||||
all_of(_IIter, _IIter, _Predicate);
|
||||
|
||||
template<typename _IIter, typename _Predicate>
|
||||
bool
|
||||
any_of(_IIter, _IIter, _Predicate);
|
||||
|
||||
template<typename _IIter, typename _Predicate>
|
||||
bool
|
||||
none_of(_IIter, _IIter, _Predicate);
|
||||
|
||||
template<typename _IIter, typename _Predicate>
|
||||
_IIter
|
||||
find_if_not(_IIter, _IIter, _Predicate);
|
||||
#endif
|
||||
|
||||
template<typename _IIter1, typename _IIter2>
|
||||
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<typename _IIter, typename _Predicate>
|
||||
_IIter
|
||||
_IIter
|
||||
find_if(_IIter, _IIter, _Predicate);
|
||||
|
||||
template<typename _IIter, typename _Funct>
|
||||
|
@ -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<typename _InputIterator, typename _Predicate>
|
||||
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<typename _RandomAccessIterator, typename _Predicate>
|
||||
_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<typename _InputIterator, typename _Predicate>
|
||||
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<typename _InputIterator, typename _Predicate>
|
||||
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<typename _InputIterator, typename _Predicate>
|
||||
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<typename _InputIterator, typename _Predicate>
|
||||
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<typename _BidirectionalIterator, typename _OutputIterator>
|
||||
_OutputIterator
|
||||
reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last,
|
||||
_OutputIterator __result)
|
||||
_OutputIterator __result)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_BidirectionalIteratorConcept<
|
||||
|
71
libstdc++-v3/testsuite/25_algorithms/all_of/1.cc
Normal file
71
libstdc++-v3/testsuite/25_algorithms/all_of/1.cc
Normal file
@ -0,0 +1,71 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_iterators.h>
|
||||
|
||||
using __gnu_test::test_container;
|
||||
using __gnu_test::input_iterator_wrapper;
|
||||
|
||||
typedef test_container<int, input_iterator_wrapper> 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;
|
||||
}
|
50
libstdc++-v3/testsuite/25_algorithms/all_of/check_type.cc
Normal file
50
libstdc++-v3/testsuite/25_algorithms/all_of/check_type.cc
Normal file
@ -0,0 +1,50 @@
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <testsuite_iterators.h>
|
||||
|
||||
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<X>& begin,
|
||||
input_iterator_wrapper<X>& end)
|
||||
{ return std::all_of(begin, end, pred_function); }
|
||||
|
||||
bool
|
||||
test2(input_iterator_wrapper<X>& begin,
|
||||
input_iterator_wrapper<X>& end)
|
||||
{ return std::all_of(begin, end, pred_obj()); }
|
@ -0,0 +1,46 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <functional>
|
||||
#include <testsuite_api.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
using __gnu_test::NonDefaultConstructible;
|
||||
|
||||
typedef NonDefaultConstructible value_type;
|
||||
typedef value_type* iterator_type;
|
||||
typedef std::pointer_to_unary_function<value_type, bool> predicate_type;
|
||||
|
||||
template bool all_of(iterator_type, iterator_type, predicate_type);
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <testsuite_character.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
using __gnu_test::pod_int;
|
||||
|
||||
typedef pod_int value_type;
|
||||
typedef value_type* iterator_type;
|
||||
typedef std::pointer_to_unary_function<value_type, bool> predicate_type;
|
||||
|
||||
template bool all_of(iterator_type, iterator_type, predicate_type);
|
||||
}
|
71
libstdc++-v3/testsuite/25_algorithms/any_of/1.cc
Normal file
71
libstdc++-v3/testsuite/25_algorithms/any_of/1.cc
Normal file
@ -0,0 +1,71 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_iterators.h>
|
||||
|
||||
using __gnu_test::test_container;
|
||||
using __gnu_test::input_iterator_wrapper;
|
||||
|
||||
typedef test_container<int, input_iterator_wrapper> 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;
|
||||
}
|
50
libstdc++-v3/testsuite/25_algorithms/any_of/check_type.cc
Normal file
50
libstdc++-v3/testsuite/25_algorithms/any_of/check_type.cc
Normal file
@ -0,0 +1,50 @@
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <testsuite_iterators.h>
|
||||
|
||||
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<X>& begin,
|
||||
input_iterator_wrapper<X>& end)
|
||||
{ return std::any_of(begin, end, pred_function); }
|
||||
|
||||
bool
|
||||
test2(input_iterator_wrapper<X>& begin,
|
||||
input_iterator_wrapper<X>& end)
|
||||
{ return std::any_of(begin, end, pred_obj()); }
|
@ -0,0 +1,46 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <functional>
|
||||
#include <testsuite_api.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
using __gnu_test::NonDefaultConstructible;
|
||||
|
||||
typedef NonDefaultConstructible value_type;
|
||||
typedef value_type* iterator_type;
|
||||
typedef std::pointer_to_unary_function<value_type, bool> predicate_type;
|
||||
|
||||
template bool any_of(iterator_type, iterator_type, predicate_type);
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <testsuite_character.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
using __gnu_test::pod_int;
|
||||
|
||||
typedef pod_int value_type;
|
||||
typedef value_type* iterator_type;
|
||||
typedef std::pointer_to_unary_function<value_type, bool> predicate_type;
|
||||
|
||||
template bool any_of(iterator_type, iterator_type, predicate_type);
|
||||
}
|
60
libstdc++-v3/testsuite/25_algorithms/copy_if/check_type.cc
Normal file
60
libstdc++-v3/testsuite/25_algorithms/copy_if/check_type.cc
Normal file
@ -0,0 +1,60 @@
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <testsuite_iterators.h>
|
||||
|
||||
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<Z>
|
||||
test1(input_iterator_wrapper<X>& begin,
|
||||
input_iterator_wrapper<X>& end,
|
||||
output_iterator_wrapper<Z>& output)
|
||||
{ return std::copy_if(begin, end, output, pred_function); }
|
||||
|
||||
output_iterator_wrapper<Z>
|
||||
test2(input_iterator_wrapper<X>& begin,
|
||||
input_iterator_wrapper<X>& end,
|
||||
output_iterator_wrapper<Z>& output)
|
||||
{ return std::copy_if(begin, end, output, pred_obj()); }
|
@ -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;
|
||||
}
|
||||
|
74
libstdc++-v3/testsuite/25_algorithms/find_if_not/1.cc
Normal file
74
libstdc++-v3/testsuite/25_algorithms/find_if_not/1.cc
Normal file
@ -0,0 +1,74 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_iterators.h>
|
||||
|
||||
using __gnu_test::test_container;
|
||||
using __gnu_test::input_iterator_wrapper;
|
||||
|
||||
typedef test_container<int, input_iterator_wrapper> 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;
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <testsuite_iterators.h>
|
||||
|
||||
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<X>
|
||||
test1(input_iterator_wrapper<X>& begin,
|
||||
input_iterator_wrapper<X>& end)
|
||||
{ return std::find_if_not(begin, end, pred_function); }
|
||||
|
||||
input_iterator_wrapper<X>
|
||||
test2(input_iterator_wrapper<X>& begin,
|
||||
input_iterator_wrapper<X>& end)
|
||||
{ return std::find_if_not(begin, end, pred_obj()); }
|
@ -0,0 +1,46 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <functional>
|
||||
#include <testsuite_api.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
using __gnu_test::NonDefaultConstructible;
|
||||
|
||||
typedef NonDefaultConstructible value_type;
|
||||
typedef value_type* iterator_type;
|
||||
typedef std::pointer_to_unary_function<value_type, bool> predicate_type;
|
||||
|
||||
template iterator_type find_if_not(iterator_type, iterator_type, predicate_type);
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <testsuite_character.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
using __gnu_test::pod_int;
|
||||
|
||||
typedef pod_int value_type;
|
||||
typedef value_type* iterator_type;
|
||||
typedef std::pointer_to_unary_function<value_type, bool> predicate_type;
|
||||
|
||||
template iterator_type find_if_not(iterator_type, iterator_type, predicate_type);
|
||||
}
|
@ -32,9 +32,27 @@ namespace std
|
||||
find(_IIter, _IIter, const _Tp&);
|
||||
|
||||
template<typename _IIter, typename _Predicate>
|
||||
_IIter
|
||||
_IIter
|
||||
find_if(_IIter, _IIter, _Predicate);
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
template<typename _IIter, typename _Predicate>
|
||||
bool
|
||||
all_of(_IIter, _IIter, _Predicate);
|
||||
|
||||
template<typename _IIter, typename _Predicate>
|
||||
bool
|
||||
any_of(_IIter, _IIter, _Predicate);
|
||||
|
||||
template<typename _IIter, typename _Predicate>
|
||||
bool
|
||||
none_of(_IIter, _IIter, _Predicate);
|
||||
|
||||
template<typename _IIter, typename _Predicate>
|
||||
_IIter
|
||||
find_if_not(_IIter, _IIter, _Predicate);
|
||||
#endif
|
||||
|
||||
template<typename _FIter1, typename _FIter2>
|
||||
_FIter1
|
||||
find_end(_FIter1, _FIter1, _FIter2, _FIter2);
|
||||
|
71
libstdc++-v3/testsuite/25_algorithms/none_of/1.cc
Normal file
71
libstdc++-v3/testsuite/25_algorithms/none_of/1.cc
Normal file
@ -0,0 +1,71 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_iterators.h>
|
||||
|
||||
using __gnu_test::test_container;
|
||||
using __gnu_test::input_iterator_wrapper;
|
||||
|
||||
typedef test_container<int, input_iterator_wrapper> 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;
|
||||
}
|
50
libstdc++-v3/testsuite/25_algorithms/none_of/check_type.cc
Normal file
50
libstdc++-v3/testsuite/25_algorithms/none_of/check_type.cc
Normal file
@ -0,0 +1,50 @@
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <testsuite_iterators.h>
|
||||
|
||||
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<X>& begin,
|
||||
input_iterator_wrapper<X>& end)
|
||||
{ return std::none_of(begin, end, pred_function); }
|
||||
|
||||
bool
|
||||
test2(input_iterator_wrapper<X>& begin,
|
||||
input_iterator_wrapper<X>& end)
|
||||
{ return std::none_of(begin, end, pred_obj()); }
|
@ -0,0 +1,46 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <functional>
|
||||
#include <testsuite_api.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
using __gnu_test::NonDefaultConstructible;
|
||||
|
||||
typedef NonDefaultConstructible value_type;
|
||||
typedef value_type* iterator_type;
|
||||
typedef std::pointer_to_unary_function<value_type, bool> predicate_type;
|
||||
|
||||
template bool none_of(iterator_type, iterator_type, predicate_type);
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <testsuite_character.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
using __gnu_test::pod_int;
|
||||
|
||||
typedef pod_int value_type;
|
||||
typedef value_type* iterator_type;
|
||||
typedef std::pointer_to_unary_function<value_type, bool> predicate_type;
|
||||
|
||||
template bool none_of(iterator_type, iterator_type, predicate_type);
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
// 2008-06-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// 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 <algorithm>
|
||||
#include <testsuite_iterators.h>
|
||||
|
||||
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<Z>
|
||||
test1(input_iterator_wrapper<X>& begin,
|
||||
input_iterator_wrapper<X>& end,
|
||||
output_iterator_wrapper<Z>& output)
|
||||
{ return std::remove_copy_if(begin, end, output, pred_function); }
|
||||
|
||||
output_iterator_wrapper<Z>
|
||||
test2(input_iterator_wrapper<X>& begin,
|
||||
input_iterator_wrapper<X>& end,
|
||||
output_iterator_wrapper<Z>& output)
|
||||
{ return std::remove_copy_if(begin, end, output, pred_obj()); }
|
Loading…
Reference in New Issue
Block a user