[multiple changes]
2008-09-16 Chris Fairles <chris.fairles@gmail.com> * testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc: New. * testsuite/25_algorithms/min/requirements/explicit_instantiation/ pod2.cc: Likewise. * testsuite/25_algorithms/min/3.cc: Likewise. * testsuite/25_algorithms/min/4.cc: Likewise. * testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc: Likewise. * testsuite/25_algorithms/max/requirements/explicit_instantiation/ pod2.cc: Likewise. * testsuite/25_algorithms/max/3.cc: Likewise. * testsuite/25_algorithms/max/4.cc: Likewise. * testsuite/25_algorithms/minmax/requirements/explicit_instantiation/ 3.cc: Likewise. * testsuite/25_algorithms/minmax/requirements/explicit_instantiation/ pod2.cc: Likewise. * testsuite/25_algorithms/minmax/2.cc: Likewise. * testsuite/25_algorithms/minmax/3.cc: Likewise. 2008-09-16 Paolo Carlini <paolo.carlini@oracle.com> * include/bits/stl_algo.h (min(initializer_list<>), min(initializer_list<>, Compare), max(initializer_list<>), max(initializer_list<>, Compare), minmax(initializer_list<>), minmax(initializer_list<>, Compare)): Add in C++0x mode. * include/bits/algorithmfwd.h: Add. * testsuite/25_algorithms/headers/algorithm/synopsis.cc: Likewise. From-SVN: r140404
This commit is contained in:
parent
b5fb36eecd
commit
1edd1a8317
16 changed files with 732 additions and 1 deletions
|
@ -1,3 +1,33 @@
|
|||
2008-09-16 Chris Fairles <chris.fairles@gmail.com>
|
||||
|
||||
* testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc:
|
||||
New.
|
||||
* testsuite/25_algorithms/min/requirements/explicit_instantiation/
|
||||
pod2.cc: Likewise.
|
||||
* testsuite/25_algorithms/min/3.cc: Likewise.
|
||||
* testsuite/25_algorithms/min/4.cc: Likewise.
|
||||
* testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc:
|
||||
Likewise.
|
||||
* testsuite/25_algorithms/max/requirements/explicit_instantiation/
|
||||
pod2.cc: Likewise.
|
||||
* testsuite/25_algorithms/max/3.cc: Likewise.
|
||||
* testsuite/25_algorithms/max/4.cc: Likewise.
|
||||
* testsuite/25_algorithms/minmax/requirements/explicit_instantiation/
|
||||
3.cc: Likewise.
|
||||
* testsuite/25_algorithms/minmax/requirements/explicit_instantiation/
|
||||
pod2.cc: Likewise.
|
||||
* testsuite/25_algorithms/minmax/2.cc: Likewise.
|
||||
* testsuite/25_algorithms/minmax/3.cc: Likewise.
|
||||
|
||||
2008-09-16 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* include/bits/stl_algo.h (min(initializer_list<>),
|
||||
min(initializer_list<>, Compare), max(initializer_list<>),
|
||||
max(initializer_list<>, Compare), minmax(initializer_list<>),
|
||||
minmax(initializer_list<>, Compare)): Add in C++0x mode.
|
||||
* include/bits/algorithmfwd.h: Add.
|
||||
* testsuite/25_algorithms/headers/algorithm/synopsis.cc: Likewise.
|
||||
|
||||
2008-09-13 Chris Fairles <chris.fairles@gmail.com>
|
||||
|
||||
* testsuite/30_threads/thread/algorithm/1.cc: Join thread before
|
||||
|
|
|
@ -115,6 +115,7 @@
|
|||
#include <bits/c++config.h>
|
||||
#include <bits/stl_pair.h>
|
||||
#include <bits/stl_iterator_base_types.h>
|
||||
#include <initializer_list>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
|
||||
|
@ -316,6 +317,30 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
template<typename _FIter, typename _Compare>
|
||||
pair<_FIter, _FIter>
|
||||
minmax_element(_FIter, _FIter, _Compare);
|
||||
|
||||
template<typename _Tp>
|
||||
const _Tp&
|
||||
min(initializer_list<_Tp>);
|
||||
|
||||
template<typename _Tp, typename _Compare>
|
||||
const _Tp&
|
||||
min(initializer_list<_Tp>, _Compare);
|
||||
|
||||
template<typename _Tp>
|
||||
const _Tp&
|
||||
max(initializer_list<_Tp>);
|
||||
|
||||
template<typename _Tp, typename _Compare>
|
||||
const _Tp&
|
||||
max(initializer_list<_Tp>, _Compare);
|
||||
|
||||
template<typename _Tp>
|
||||
pair<const _Tp&, const _Tp&>
|
||||
minmax(initializer_list<_Tp>);
|
||||
|
||||
template<typename _Tp, typename _Compare>
|
||||
pair<const _Tp&, const _Tp&>
|
||||
minmax(initializer_list<_Tp>, _Compare);
|
||||
#endif
|
||||
|
||||
// mismatch
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
#include <bits/stl_heap.h>
|
||||
#include <bits/stl_tempbuf.h> // for _Temporary_buffer
|
||||
#include <debug/debug.h>
|
||||
#include <initializer_list>
|
||||
|
||||
// See concept_check.h for the __glibcxx_*_requires macros.
|
||||
|
||||
|
@ -4092,6 +4093,45 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
|
||||
return std::make_pair(__min, __max);
|
||||
}
|
||||
|
||||
// N2722.
|
||||
template<typename _Tp>
|
||||
inline const _Tp&
|
||||
min(initializer_list<_Tp> __l)
|
||||
{ return *std::min_element(__l.begin(), __l.end()); }
|
||||
|
||||
template<typename _Tp, typename _Compare>
|
||||
inline const _Tp&
|
||||
min(initializer_list<_Tp> __l, _Compare __comp)
|
||||
{ return *std::min_element(__l.begin(), __l.end(), __comp); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline const _Tp&
|
||||
max(initializer_list<_Tp> __l)
|
||||
{ return *std::max_element(__l.begin(), __l.end()); }
|
||||
|
||||
template<typename _Tp, typename _Compare>
|
||||
inline const _Tp&
|
||||
max(initializer_list<_Tp> __l, _Compare __comp)
|
||||
{ return *std::max_element(__l.begin(), __l.end(), __comp); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline pair<const _Tp&, const _Tp&>
|
||||
minmax(initializer_list<_Tp> __l)
|
||||
{
|
||||
pair<const _Tp*, const _Tp*> __p =
|
||||
std::minmax_element(__l.begin(), __l.end());
|
||||
return std::make_pair(*__p.first, *__p.second);
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _Compare>
|
||||
inline pair<const _Tp&, const _Tp&>
|
||||
minmax(initializer_list<_Tp> __l, _Compare __comp)
|
||||
{
|
||||
pair<const _Tp*, const _Tp*> __p =
|
||||
std::minmax_element(__l.begin(), __l.end(), __comp);
|
||||
return std::make_pair(*__p.first, *__p.second);
|
||||
}
|
||||
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
||||
|
||||
_GLIBCXX_END_NAMESPACE
|
||||
|
|
|
@ -529,8 +529,32 @@ namespace std
|
|||
minmax_element(_FIter, _FIter);
|
||||
|
||||
template<typename _FIter, typename _Compare>
|
||||
pair<_FIter, _FIter>
|
||||
pair<_FIter, _FIter>
|
||||
minmax_element(_FIter, _FIter, _Compare);
|
||||
|
||||
template<typename _Tp>
|
||||
const _Tp&
|
||||
min(initializer_list<_Tp>);
|
||||
|
||||
template<typename _Tp, typename _Compare>
|
||||
const _Tp&
|
||||
min(initializer_list<_Tp>, _Compare);
|
||||
|
||||
template<typename _Tp>
|
||||
const _Tp&
|
||||
max(initializer_list<_Tp>);
|
||||
|
||||
template<typename _Tp, typename _Compare>
|
||||
const _Tp&
|
||||
max(initializer_list<_Tp>, _Compare);
|
||||
|
||||
template<typename _Tp>
|
||||
pair<const _Tp&, const _Tp&>
|
||||
minmax(initializer_list<_Tp>);
|
||||
|
||||
template<typename _Tp, typename _Compare>
|
||||
pair<const _Tp&, const _Tp&>
|
||||
minmax(initializer_list<_Tp>, _Compare);
|
||||
#endif
|
||||
|
||||
template<typename _IIter1, typename _IIter2>
|
||||
|
|
48
libstdc++-v3/testsuite/25_algorithms/max/3.cc
Normal file
48
libstdc++-v3/testsuite/25_algorithms/max/3.cc
Normal file
|
@ -0,0 +1,48 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 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 <functional>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
const int& x = std::max({1, 3, 2});
|
||||
const int& y = std::max({4, 3, 2});
|
||||
const int& z = std::max({3, 2, 4});
|
||||
VERIFY( x == 3 );
|
||||
VERIFY( y == 4 );
|
||||
VERIFY( z == 4 );
|
||||
|
||||
const int& xc = std::max({1, 2, 3}, std::greater<int>());
|
||||
const int& yc = std::max({4, 3, 2}, std::greater<int>());
|
||||
const int& zc = std::max({2, 4, 3}, std::greater<int>());
|
||||
VERIFY( xc == 1 );
|
||||
VERIFY( yc == 2 );
|
||||
VERIFY( zc == 2 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
55
libstdc++-v3/testsuite/25_algorithms/max/4.cc
Normal file
55
libstdc++-v3/testsuite/25_algorithms/max/4.cc
Normal file
|
@ -0,0 +1,55 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 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 <functional>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
const int& z = std::max({1, 2, 3, 4, 5, 6, 7});
|
||||
const double& w = std::max({2.0, 1.0, 3.2, 4.5, 5.0, 6.0, 7.0});
|
||||
const int& y = std::max({2, 3, 1, 4, 5, 6, 7});
|
||||
const float& x = std::max({2.0f, 3.0f, 5.0f, 1.0f, 7.0f, 6.0f});
|
||||
VERIFY( z == 7 );
|
||||
VERIFY( w == 7.0 );
|
||||
VERIFY( y == 7 );
|
||||
VERIFY( x == 7.0f );
|
||||
|
||||
const int& zc = std::max({1, 2, 3, 4, 5, 6, 7}, std::greater<int>());
|
||||
const double& wc = std::max({2.0, 1.0, 3.2, 4.5, 5.0},
|
||||
std::greater<double>());
|
||||
const int& yc = std::max({2, 7, 1, 4, 5, 6, 3}, std::greater<int>());
|
||||
const float& xc = std::max({2.0f, 3.0f, 5.0f, 1.0f},
|
||||
std::greater<float>());
|
||||
|
||||
VERIFY( zc == 1 );
|
||||
VERIFY( wc == 1.0 );
|
||||
VERIFY( yc == 1 );
|
||||
VERIFY( xc == 1.0f );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-do compile }
|
||||
|
||||
// 2008-09-16 Chris Fairles <chris.fairles@gmail.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::less<value_type> compare_type;
|
||||
|
||||
template const value_type& max(initializer_list<value_type>);
|
||||
template const value_type& max(initializer_list<value_type>, compare_type);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-do compile }
|
||||
|
||||
// 2008-09-16 Chris Fairles <chris.fairles@gmail.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_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 const value_type& max(initializer_list<value_type>);
|
||||
template const value_type& max(initializer_list<value_type>, compare_type);
|
||||
}
|
48
libstdc++-v3/testsuite/25_algorithms/min/3.cc
Normal file
48
libstdc++-v3/testsuite/25_algorithms/min/3.cc
Normal file
|
@ -0,0 +1,48 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 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 <functional>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
const int& z = std::min({1, 3, 2});
|
||||
const int& w = std::min({4, 3, 5});
|
||||
const int& y = std::min({4, 3, 2});
|
||||
VERIFY( z == 1 );
|
||||
VERIFY( w == 3 );
|
||||
VERIFY( y == 2 );
|
||||
|
||||
const int& zc = std::min({1, 3, 2}, std::greater<int>());
|
||||
const int& wc = std::min({4, 3, 5}, std::greater<int>());
|
||||
const int& yc = std::min({4, 3, 2}, std::greater<int>());
|
||||
VERIFY( zc == 3 );
|
||||
VERIFY( wc == 5 );
|
||||
VERIFY( yc == 4 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
56
libstdc++-v3/testsuite/25_algorithms/min/4.cc
Normal file
56
libstdc++-v3/testsuite/25_algorithms/min/4.cc
Normal file
|
@ -0,0 +1,56 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 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 <functional>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
const int& z = std::min({1, 2, 3, 4, 5, 6, 7});
|
||||
const double& w = std::min({2.0, 1.0, 3.2, 4.5, 5.0, 6.0, 7.0});
|
||||
const int& y = std::min({2, 3, 1, 4, 5, 6, 7});
|
||||
const float& x = std::min({2.0f, 3.0f, 5.0f, 1.0f, 7.0f, 6.0f});
|
||||
VERIFY( z == 1 );
|
||||
VERIFY( w == 1.0 );
|
||||
VERIFY( y == 1 );
|
||||
VERIFY( x == 1.0f );
|
||||
|
||||
|
||||
const int& zc = std::min({1, 2, 3, 4, 5, 6, 7}, std::greater<int>());
|
||||
const double& wc = std::min({2.0, 1.0, 3.2, 4.5, 5.0, 6.0, 7.0},
|
||||
std::greater<double>());
|
||||
const int& yc = std::min({2, 7, 1, 4, 5, 6, 3}, std::greater<int>());
|
||||
const float& xc = std::min({2.0f, 3.0f, 5.0f, 1.0f, 7.0f, 6.0f},
|
||||
std::greater<float>());
|
||||
|
||||
VERIFY( zc == 7 );
|
||||
VERIFY( wc == 7.0 );
|
||||
VERIFY( yc == 7 );
|
||||
VERIFY( xc == 7.0f );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-do compile }
|
||||
|
||||
// 2008-09-16 Chris Fairles <chris.fairles@gmail.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::less<value_type> compare_type;
|
||||
|
||||
template const value_type& min(initializer_list<value_type>);
|
||||
template const value_type& min(initializer_list<value_type>, compare_type);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-do compile }
|
||||
|
||||
// 2008-09-16 Chris Fairles <chris.fairles@gmail.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_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 const value_type& min(initializer_list<value_type>);
|
||||
template const value_type& min(initializer_list<value_type>, compare_type);
|
||||
}
|
62
libstdc++-v3/testsuite/25_algorithms/minmax/2.cc
Normal file
62
libstdc++-v3/testsuite/25_algorithms/minmax/2.cc
Normal file
|
@ -0,0 +1,62 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2008-09-16 Chris Fairles <chris.fairles@gmail.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 <functional>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::pair<const int&, const int&> z = std::minmax({1, 2, 3});
|
||||
std::pair<const int&, const int&> w = std::minmax({4, 3, 5, 4});
|
||||
std::pair<const int&, const int&> y = std::minmax({4, 5, 3, 7, 3});
|
||||
VERIFY( z.first == 1 );
|
||||
VERIFY( z.second == 3 );
|
||||
VERIFY( w.first == 3 );
|
||||
VERIFY( w.second == 5 );
|
||||
VERIFY( y.first == 3 );
|
||||
VERIFY( y.second == 7 );
|
||||
|
||||
std::pair<const int&, const int&> zc =
|
||||
std::minmax({1, 2, 3}, std::greater<int>());
|
||||
|
||||
std::pair<const int&, const int&> wc =
|
||||
std::minmax({4, 3, 5, 4}, std::greater<int>());
|
||||
|
||||
std::pair<const int&, const int&> yc =
|
||||
std::minmax({4, 5, 3, 7, 3}, std::greater<int>());
|
||||
|
||||
VERIFY( zc.first == 3 );
|
||||
VERIFY( zc.second == 1 );
|
||||
VERIFY( wc.first == 5 );
|
||||
VERIFY( wc.second == 3 );
|
||||
VERIFY( yc.first == 7 );
|
||||
VERIFY( yc.second == 3 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
57
libstdc++-v3/testsuite/25_algorithms/minmax/3.cc
Normal file
57
libstdc++-v3/testsuite/25_algorithms/minmax/3.cc
Normal file
|
@ -0,0 +1,57 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2008-09-16 Chris Fairles <chris.fairles@gmail.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 <functional>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
struct compare_counter
|
||||
: std::binary_function<int, int, bool>
|
||||
{
|
||||
static int count;
|
||||
|
||||
bool operator()(int a, int b) const
|
||||
{
|
||||
++count;
|
||||
return a < b;
|
||||
}
|
||||
};
|
||||
|
||||
int compare_counter::count = 0;
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::pair<const int&, const int&> z = std::minmax({1, 2, 3, 4, 5, 6, 7, 8},
|
||||
compare_counter());
|
||||
|
||||
// If N is the number of arguments in the minmax function call,
|
||||
// 25.3.7 specifies that at most 3N/2 comparisons are allowed.
|
||||
VERIFY(compare_counter::count <= (3 * 8 / 2));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-do compile }
|
||||
|
||||
// 2008-09-16 Chris Fairles <chris.fairles@gmail.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::less<value_type> compare_type;
|
||||
|
||||
template pair<const value_type&, const value_type&>
|
||||
minmax(initializer_list<value_type>);
|
||||
template pair<const value_type&, const value_type&>
|
||||
minmax(initializer_list<value_type>, compare_type);
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-do compile }
|
||||
|
||||
// 2008-09-16 Chris Fairles <chris.fairles@gmail.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_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(initializer_list<value_type>);
|
||||
template pair<const value_type&, const value_type&>
|
||||
minmax(initializer_list<value_type>, compare_type);
|
||||
}
|
Loading…
Add table
Reference in a new issue