From 1edd1a831747f2aa772b8cc6cf476965112b2bff Mon Sep 17 00:00:00 2001
From: Paolo Carlini <paolo@gcc.gnu.org>
Date: Tue, 16 Sep 2008 23:17:09 +0000
Subject: [PATCH] [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
---
 libstdc++-v3/ChangeLog                        | 30 +++++++++
 libstdc++-v3/include/bits/algorithmfwd.h      | 25 ++++++++
 libstdc++-v3/include/bits/stl_algo.h          | 40 ++++++++++++
 .../headers/algorithm/synopsis.cc             | 26 +++++++-
 libstdc++-v3/testsuite/25_algorithms/max/3.cc | 48 ++++++++++++++
 libstdc++-v3/testsuite/25_algorithms/max/4.cc | 55 ++++++++++++++++
 .../requirements/explicit_instantiation/3.cc  | 47 ++++++++++++++
 .../explicit_instantiation/pod2.cc            | 47 ++++++++++++++
 libstdc++-v3/testsuite/25_algorithms/min/3.cc | 48 ++++++++++++++
 libstdc++-v3/testsuite/25_algorithms/min/4.cc | 56 +++++++++++++++++
 .../requirements/explicit_instantiation/3.cc  | 47 ++++++++++++++
 .../explicit_instantiation/pod2.cc            | 47 ++++++++++++++
 .../testsuite/25_algorithms/minmax/2.cc       | 62 +++++++++++++++++++
 .../testsuite/25_algorithms/minmax/3.cc       | 57 +++++++++++++++++
 .../requirements/explicit_instantiation/3.cc  | 49 +++++++++++++++
 .../explicit_instantiation/pod2.cc            | 49 +++++++++++++++
 16 files changed, 732 insertions(+), 1 deletion(-)
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/max/3.cc
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/max/4.cc
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod2.cc
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/min/3.cc
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/min/4.cc
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod2.cc
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax/2.cc
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax/3.cc
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/3.cc
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod2.cc

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index bd89e6e1346c..3c2d291778e1 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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
diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h
index 6fefe46b525d..95ff72b79d5f 100644
--- a/libstdc++-v3/include/bits/algorithmfwd.h
+++ b/libstdc++-v3/include/bits/algorithmfwd.h
@@ -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
diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h
index 40ce60b23ef1..42ada9986f39 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -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
diff --git a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc
index 2d73e6f15bc8..3bc8eb2a7649 100644
--- a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc
@@ -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>
diff --git a/libstdc++-v3/testsuite/25_algorithms/max/3.cc b/libstdc++-v3/testsuite/25_algorithms/max/3.cc
new file mode 100644
index 000000000000..e3a01159c8a1
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/max/3.cc
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/25_algorithms/max/4.cc b/libstdc++-v3/testsuite/25_algorithms/max/4.cc
new file mode 100644
index 000000000000..523728f5137d
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/max/4.cc
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc
new file mode 100644
index 000000000000..e4ac6cb607b4
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc
@@ -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);
+} 
diff --git a/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod2.cc b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod2.cc
new file mode 100644
index 000000000000..55f2eae65452
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod2.cc
@@ -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);
+} 
diff --git a/libstdc++-v3/testsuite/25_algorithms/min/3.cc b/libstdc++-v3/testsuite/25_algorithms/min/3.cc
new file mode 100644
index 000000000000..c9617249824d
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/min/3.cc
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/25_algorithms/min/4.cc b/libstdc++-v3/testsuite/25_algorithms/min/4.cc
new file mode 100644
index 000000000000..2d19ac79b032
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/min/4.cc
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc
new file mode 100644
index 000000000000..1d6e7aedeb88
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc
@@ -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);
+} 
diff --git a/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod2.cc b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod2.cc
new file mode 100644
index 000000000000..98c8413c2a62
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod2.cc
@@ -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);
+} 
diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/2.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/2.cc
new file mode 100644
index 000000000000..f19782eb45bd
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/minmax/2.cc
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/3.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/3.cc
new file mode 100644
index 000000000000..0cb438a4360a
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/minmax/3.cc
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/3.cc
new file mode 100644
index 000000000000..71fab66fddd6
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/3.cc
@@ -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);
+}
diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod2.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod2.cc
new file mode 100644
index 000000000000..d5285930ddf5
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod2.cc
@@ -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);
+}