stl_algo.h (minmax, [...]): Add.
2007-11-02 Paolo Carlini <pcarlini@suse.de> * include/bits/stl_algo.h (minmax, minmax_element): Add. * include/bits/algorithmfwd.h: Update. * testsuite/25_algorithms/minmax/requirements/ explicit_instantiation/2.cc: New. * testsuite/25_algorithms/minmax/requirements/ explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/minmax/1.cc: Likewise. * testsuite/25_algorithms/minmax_element/check_type.cc: Likewise. * testsuite/25_algorithms/minmax_element/requirements/ explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/minmax_element/requirements/ explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/minmax_element/1.cc: Likewise. * testsuite/25_algorithms/headers/algorithm/synopsis.cc: Update. From-SVN: r129853
This commit is contained in:
parent
59b567fbca
commit
f6547b6818
11 changed files with 671 additions and 0 deletions
|
@ -1,3 +1,20 @@
|
|||
2007-11-02 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/bits/stl_algo.h (minmax, minmax_element): Add.
|
||||
* include/bits/algorithmfwd.h: Update.
|
||||
* testsuite/25_algorithms/minmax/requirements/
|
||||
explicit_instantiation/2.cc: New.
|
||||
* testsuite/25_algorithms/minmax/requirements/
|
||||
explicit_instantiation/pod.cc: Likewise.
|
||||
* testsuite/25_algorithms/minmax/1.cc: Likewise.
|
||||
* testsuite/25_algorithms/minmax_element/check_type.cc: Likewise.
|
||||
* testsuite/25_algorithms/minmax_element/requirements/
|
||||
explicit_instantiation/2.cc: Likewise.
|
||||
* testsuite/25_algorithms/minmax_element/requirements/
|
||||
explicit_instantiation/pod.cc: Likewise.
|
||||
* testsuite/25_algorithms/minmax_element/1.cc: Likewise.
|
||||
* testsuite/25_algorithms/headers/algorithm/synopsis.cc: Update.
|
||||
|
||||
2007-11-02 Johannes Singler <singler@ira.uka.de>
|
||||
|
||||
* include/parallel/workstealing.h: Replaced pragma by function
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
inplace_merge
|
||||
is_heap (C++0x)
|
||||
is_heap_until (C++0x)
|
||||
is_sorted (C++0x)
|
||||
is_sorted_until (C++0x)
|
||||
iter_swap
|
||||
lexicographical_compare
|
||||
lower_bound
|
||||
|
@ -54,6 +56,8 @@
|
|||
merge
|
||||
min
|
||||
min_element
|
||||
minmax (C++0x)
|
||||
minmax_element (C++0x)
|
||||
mismatch
|
||||
next_permutation
|
||||
nth_element
|
||||
|
@ -263,6 +267,25 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
min(const _Tp&, const _Tp&, _Compare);
|
||||
|
||||
// min_element
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
template<typename _Tp>
|
||||
pair<const _Tp&, const _Tp&>
|
||||
minmax(const _Tp&, const _Tp&);
|
||||
|
||||
template<typename _Tp, typename _Compare>
|
||||
pair<const _Tp&, const _Tp&>
|
||||
minmax(const _Tp&, const _Tp&, _Compare);
|
||||
|
||||
template<typename _FIter>
|
||||
pair<_FIter, _FIter>
|
||||
minmax_element(_FIter, _FIter);
|
||||
|
||||
template<typename _FIter, typename _Compare>
|
||||
pair<_FIter, _FIter>
|
||||
minmax_element(_FIter, _FIter, _Compare);
|
||||
#endif
|
||||
|
||||
// mismatch
|
||||
|
||||
template<typename _BIter>
|
||||
|
|
|
@ -3745,6 +3745,189 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
return __next;
|
||||
return __next;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determines min and max at once as an ordered pair.
|
||||
* @param a A thing of arbitrary type.
|
||||
* @param b Another thing of arbitrary type.
|
||||
* @return A pair(b, a) if b is smaller than a, pair(a, b) otherwise.
|
||||
*/
|
||||
template<typename _Tp>
|
||||
inline pair<const _Tp&, const _Tp&>
|
||||
minmax(const _Tp& __a, const _Tp& __b)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
|
||||
|
||||
return __b < __a ? pair<const _Tp&, const _Tp&>(__b, __a)
|
||||
: pair<const _Tp&, const _Tp&>(__a, __b);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determines min and max at once as an ordered pair.
|
||||
* @param a A thing of arbitrary type.
|
||||
* @param b Another thing of arbitrary type.
|
||||
* @param comp A @link s20_3_3_comparisons comparison functor@endlink.
|
||||
* @return A pair(b, a) if b is smaller than a, pair(a, b) otherwise.
|
||||
*/
|
||||
template<typename _Tp, typename _Compare>
|
||||
inline pair<const _Tp&, const _Tp&>
|
||||
minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
|
||||
{
|
||||
return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a)
|
||||
: pair<const _Tp&, const _Tp&>(__a, __b);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return a pair of iterators pointing to the minimum and maximum
|
||||
* elements in a range.
|
||||
* @param first Start of range.
|
||||
* @param last End of range.
|
||||
* @return make_pair(m, M), where m is the first iterator i in
|
||||
* [first, last) such that no other element in the range is
|
||||
* smaller, and where M is the last iterator i in [first, last)
|
||||
* such that no other element in the range is larger.
|
||||
*/
|
||||
template<typename _ForwardIterator>
|
||||
pair<_ForwardIterator, _ForwardIterator>
|
||||
minmax_element(_ForwardIterator __first, _ForwardIterator __last)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
|
||||
__glibcxx_function_requires(_LessThanComparableConcept<
|
||||
typename iterator_traits<_ForwardIterator>::value_type>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
|
||||
_ForwardIterator __next = __first;
|
||||
if (__first == __last
|
||||
|| ++__next == __last)
|
||||
return std::make_pair(__first, __first);
|
||||
|
||||
_ForwardIterator __min, __max;
|
||||
if (*__next < *__first)
|
||||
{
|
||||
__min = __next;
|
||||
__max = __first;
|
||||
}
|
||||
else
|
||||
{
|
||||
__min = __first;
|
||||
__max = __next;
|
||||
}
|
||||
|
||||
__first = __next;
|
||||
++__first;
|
||||
|
||||
while (__first != __last)
|
||||
{
|
||||
__next = __first;
|
||||
if (++__next == __last)
|
||||
{
|
||||
if (*__first < *__min)
|
||||
__min = __first;
|
||||
else if (!(*__first < *__max))
|
||||
__max = __first;
|
||||
break;
|
||||
}
|
||||
|
||||
if (*__next < *__first)
|
||||
{
|
||||
if (*__next < *__min)
|
||||
__min = __next;
|
||||
if (!(*__first < *__max))
|
||||
__max = __first;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*__first < *__min)
|
||||
__min = __first;
|
||||
if (!(*__next < *__max))
|
||||
__max = __next;
|
||||
}
|
||||
|
||||
__first = __next;
|
||||
++__first;
|
||||
}
|
||||
|
||||
return std::make_pair(__min, __max);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return a pair of iterators pointing to the minimum and maximum
|
||||
* elements in a range.
|
||||
* @param first Start of range.
|
||||
* @param last End of range.
|
||||
* @param comp Comparison functor.
|
||||
* @return make_pair(m, M), where m is the first iterator i in
|
||||
* [first, last) such that no other element in the range is
|
||||
* smaller, and where M is the last iterator i in [first, last)
|
||||
* such that no other element in the range is larger.
|
||||
*/
|
||||
template<typename _ForwardIterator, typename _Compare>
|
||||
pair<_ForwardIterator, _ForwardIterator>
|
||||
minmax_element(_ForwardIterator __first, _ForwardIterator __last,
|
||||
_Compare __comp)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
|
||||
__glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
|
||||
typename iterator_traits<_ForwardIterator>::value_type,
|
||||
typename iterator_traits<_ForwardIterator>::value_type>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
|
||||
_ForwardIterator __next = __first;
|
||||
if (__first == __last
|
||||
|| ++__next == __last)
|
||||
return std::make_pair(__first, __first);
|
||||
|
||||
_ForwardIterator __min, __max;
|
||||
if (__comp(*__next, *__first))
|
||||
{
|
||||
__min = __next;
|
||||
__max = __first;
|
||||
}
|
||||
else
|
||||
{
|
||||
__min = __first;
|
||||
__max = __next;
|
||||
}
|
||||
|
||||
__first = __next;
|
||||
++__first;
|
||||
|
||||
while (__first != __last)
|
||||
{
|
||||
__next = __first;
|
||||
if (++__next == __last)
|
||||
{
|
||||
if (__comp(*__first, *__min))
|
||||
__min = __first;
|
||||
else if (!__comp(*__first, *__max))
|
||||
__max = __first;
|
||||
break;
|
||||
}
|
||||
|
||||
if (__comp(*__next, *__first))
|
||||
{
|
||||
if (__comp(*__next, *__min))
|
||||
__min = __next;
|
||||
if (!__comp(*__first, *__max))
|
||||
__max = __first;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__comp(*__first, *__min))
|
||||
__min = __first;
|
||||
if (!__comp(*__next, *__max))
|
||||
__max = __next;
|
||||
}
|
||||
|
||||
__first = __next;
|
||||
++__first;
|
||||
}
|
||||
|
||||
return std::make_pair(__min, __max);
|
||||
}
|
||||
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
||||
|
||||
_GLIBCXX_END_NAMESPACE
|
||||
|
|
|
@ -468,6 +468,24 @@ namespace std
|
|||
_FIter
|
||||
max_element(_FIter, _FIter, _Compare);
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
template<typename _Tp>
|
||||
pair<const _Tp&, const _Tp&>
|
||||
minmax(const _Tp&, const _Tp&);
|
||||
|
||||
template<typename _Tp, typename _Compare>
|
||||
pair<const _Tp&, const _Tp&>
|
||||
minmax(const _Tp&, const _Tp&, _Compare);
|
||||
|
||||
template<typename _FIter>
|
||||
pair<_FIter, _FIter>
|
||||
minmax_element(_FIter, _FIter);
|
||||
|
||||
template<typename _FIter, typename _Compare>
|
||||
pair<_FIter, _FIter>
|
||||
minmax_element(_FIter, _FIter, _Compare);
|
||||
#endif
|
||||
|
||||
template<typename _IIter1, typename _IIter2>
|
||||
bool
|
||||
lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2);
|
||||
|
|
50
libstdc++-v3/testsuite/25_algorithms/minmax/1.cc
Normal file
50
libstdc++-v3/testsuite/25_algorithms/minmax/1.cc
Normal file
|
@ -0,0 +1,50 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2007-11-01 Paolo Carlini <pcarlini@suse.de
|
||||
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::pair<const int&, const int&> z = std::minmax(1, 2);
|
||||
std::pair<const int&, const int&> w = std::minmax(4, 3);
|
||||
VERIFY( z.first == 1 );
|
||||
VERIFY( z.second == 2 );
|
||||
VERIFY( w.first == 3 );
|
||||
VERIFY( w.second == 4 );
|
||||
|
||||
std::pair<const int&, const int&> zc = std::minmax(1, 2, std::greater<int>());
|
||||
std::pair<const int&, const int&> wc = std::minmax(4, 3, std::greater<int>());
|
||||
VERIFY( zc.first == 2 );
|
||||
VERIFY( zc.second == 1 );
|
||||
VERIFY( wc.first == 4 );
|
||||
VERIFY( wc.second == 3 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2007-11-01 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <testsuite_api.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
using __gnu_test::NonDefaultConstructible;
|
||||
|
||||
typedef NonDefaultConstructible value_type;
|
||||
typedef value_type* iterator_type;
|
||||
typedef std::less<value_type> compare_type;
|
||||
|
||||
template pair<const value_type&, const value_type&>
|
||||
minmax(const value_type&, const value_type&);
|
||||
template pair<const value_type&, const value_type&>
|
||||
minmax(const value_type&, const value_type&, compare_type);
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2007-11-01 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <algorithm>
|
||||
#include <testsuite_character.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
using __gnu_test::pod_int;
|
||||
|
||||
typedef pod_int value_type;
|
||||
typedef value_type* iterator_type;
|
||||
typedef std::less<value_type> compare_type;
|
||||
|
||||
template pair<const value_type&, const value_type&>
|
||||
minmax(const value_type&, const value_type&);
|
||||
template pair<const value_type&, const value_type&>
|
||||
minmax(const value_type&, const value_type&, compare_type);
|
||||
}
|
||||
|
139
libstdc++-v3/testsuite/25_algorithms/minmax_element/1.cc
Normal file
139
libstdc++-v3/testsuite/25_algorithms/minmax_element/1.cc
Normal file
|
@ -0,0 +1,139 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
#include <algorithm>
|
||||
#include <testsuite_iterators.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
using __gnu_test::test_container;
|
||||
using __gnu_test::forward_iterator_wrapper;
|
||||
using std::minmax_element;
|
||||
|
||||
typedef test_container<int, forward_iterator_wrapper> Container;
|
||||
typedef std::pair<forward_iterator_wrapper<int>, forward_iterator_wrapper<int> > pair_type;
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
int array[] = {0};
|
||||
Container con(array, array);
|
||||
pair_type p1 = minmax_element(con.begin(), con.end());
|
||||
VERIFY( p1.first.ptr == array );
|
||||
VERIFY( p1.second.ptr == array );
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
int array[] = {0};
|
||||
Container con(array, array + 1);
|
||||
pair_type p1 = minmax_element(con.begin(), con.end());
|
||||
VERIFY( p1.first.ptr == array );
|
||||
VERIFY( p1.second.ptr == array );
|
||||
}
|
||||
|
||||
void
|
||||
test3()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
int array[] = {0, 3};
|
||||
Container con(array, array + 2);
|
||||
pair_type p1 = minmax_element(con.begin(), con.end());
|
||||
VERIFY( p1.first.ptr == array );
|
||||
VERIFY( p1.second.ptr == array + 1 );
|
||||
}
|
||||
|
||||
void
|
||||
test4()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
int array[] = {3, 0};
|
||||
Container con(array, array + 2);
|
||||
pair_type p1 = minmax_element(con.begin(), con.end());
|
||||
VERIFY( p1.first.ptr == array + 1 );
|
||||
VERIFY( p1.second.ptr == array );
|
||||
}
|
||||
|
||||
void
|
||||
test5()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
int array[] = {3, 3};
|
||||
Container con(array, array + 2);
|
||||
pair_type p1 = minmax_element(con.begin(), con.end());
|
||||
VERIFY( p1.first.ptr == array );
|
||||
VERIFY( p1.second.ptr == array + 1 );
|
||||
}
|
||||
|
||||
void
|
||||
test6()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
int array[] = {6, 3, 0, 2, 6, 4, 0};
|
||||
Container con(array, array + 7);
|
||||
pair_type p1 = minmax_element(con.begin(), con.end());
|
||||
VERIFY( p1.first.ptr == array + 2 );
|
||||
VERIFY( p1.second.ptr == array + 4 );
|
||||
}
|
||||
|
||||
void
|
||||
test7()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
int array[] = {4, 4, 4, 6, 6, 6, 1, 1, 0, 0, 0, 2, 2};
|
||||
Container con(array, array + 13);
|
||||
pair_type p1 = minmax_element(con.begin(), con.end());
|
||||
VERIFY( p1.first.ptr == array + 8 );
|
||||
VERIFY( p1.second.ptr == array + 5 );
|
||||
}
|
||||
|
||||
void
|
||||
test8()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
int array[] = {1, 7, 5, 5, 10, 1, 0, 0, 8, 4, 4, 0, 10, 10, 10, 1};
|
||||
Container con(array, array + 16);
|
||||
pair_type p1 = minmax_element(con.begin(), con.end());
|
||||
VERIFY( p1.first.ptr == array + 6 );
|
||||
VERIFY( p1.second.ptr == array + 14 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
test4();
|
||||
test5();
|
||||
test6();
|
||||
test7();
|
||||
test8();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// { dg-do compile }
|
||||
|
||||
#include <algorithm>
|
||||
#include <testsuite_iterators.h>
|
||||
|
||||
using __gnu_test::forward_iterator_wrapper;
|
||||
|
||||
struct S { };
|
||||
|
||||
bool
|
||||
operator<(const S&, const S&) {return true;}
|
||||
|
||||
struct X { };
|
||||
|
||||
bool
|
||||
predicate(const X&, const X&) {return true;}
|
||||
|
||||
std::pair<forward_iterator_wrapper<S>, forward_iterator_wrapper<S> >
|
||||
test1(forward_iterator_wrapper<S>& s)
|
||||
{ return std::minmax_element(s,s); }
|
||||
|
||||
std::pair<forward_iterator_wrapper<X>, forward_iterator_wrapper<X> >
|
||||
test2(forward_iterator_wrapper<X>& x)
|
||||
{ return std::minmax_element(x,x,predicate); }
|
|
@ -0,0 +1,49 @@
|
|||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2007-11-01 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <testsuite_api.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
using __gnu_test::NonDefaultConstructible;
|
||||
|
||||
typedef NonDefaultConstructible value_type;
|
||||
typedef value_type* iterator_type;
|
||||
typedef std::less<value_type> compare_type;
|
||||
|
||||
template pair<iterator_type, iterator_type>
|
||||
minmax_element(iterator_type, iterator_type);
|
||||
template pair<iterator_type, iterator_type>
|
||||
minmax_element(iterator_type, iterator_type, compare_type);
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2007-11-01 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <algorithm>
|
||||
#include <testsuite_character.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
using __gnu_test::pod_int;
|
||||
|
||||
typedef pod_int value_type;
|
||||
typedef value_type* iterator_type;
|
||||
typedef std::less<value_type> compare_type;
|
||||
|
||||
template pair<iterator_type, iterator_type>
|
||||
minmax_element(iterator_type, iterator_type);
|
||||
template pair<iterator_type, iterator_type>
|
||||
minmax_element(iterator_type, iterator_type, compare_type);
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue