summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-12 12:18:06 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-12 12:18:06 +0000
commit1bbff52e3f2ab27df2701942b7c88e635d91840b (patch)
tree481d2abf3380f5c27a7cc9197b9f4117bd8a5b19 /libstdc++-v3
parent06a9142d1989f94d9ee052756c2558a139193f6d (diff)
downloadgcc-1bbff52e3f2ab27df2701942b7c88e635d91840b.tar.gz
2012-04-12 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/52942 * include/bits/stl_function.h (_Identity, _Select1st, _Select2nd): In C++11 mode do not derive from std::unary_function. * include/ext/functional (identity, select1st, select2nd): Adjust. * testsuite/23_containers/unordered_map/requirements/52942.cc: New. * testsuite/23_containers/unordered_set/requirements/52942.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186375 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog9
-rw-r--r--libstdc++-v3/include/bits/stl_function.h22
-rw-r--r--libstdc++-v3/include/ext/functional26
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_map/requirements/52942.cc37
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_set/requirements/52942.cc37
5 files changed, 121 insertions, 10 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 80321a03b9f..b8cea521cfa 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,12 @@
+2012-04-12 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR libstdc++/52942
+ * include/bits/stl_function.h (_Identity, _Select1st, _Select2nd):
+ In C++11 mode do not derive from std::unary_function.
+ * include/ext/functional (identity, select1st, select2nd): Adjust.
+ * testsuite/23_containers/unordered_map/requirements/52942.cc: New.
+ * testsuite/23_containers/unordered_set/requirements/52942.cc: Likewise.
+
2012-04-11 Jonathan Wakely <jwakely.gcc@gmail.com>
PR libstdc++/52924
diff --git a/libstdc++-v3/include/bits/stl_function.h b/libstdc++-v3/include/bits/stl_function.h
index 88655fc55c3..33d5e709628 100644
--- a/libstdc++-v3/include/bits/stl_function.h
+++ b/libstdc++-v3/include/bits/stl_function.h
@@ -1,6 +1,7 @@
// Functor implementations -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
+// 2011, 2012
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -471,7 +472,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/** @} */
template<typename _Tp>
- struct _Identity : public unary_function<_Tp,_Tp>
+ struct _Identity
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+ // unary_function itself is deprecated in C++11 and deriving from
+ // it can even be a nuisance (see PR 52942).
+ : public unary_function<_Tp,_Tp>
+#endif
{
_Tp&
operator()(_Tp& __x) const
@@ -483,8 +489,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
};
template<typename _Pair>
- struct _Select1st : public unary_function<_Pair,
- typename _Pair::first_type>
+ struct _Select1st
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+ : public unary_function<_Pair, typename _Pair::first_type>
+#endif
{
typename _Pair::first_type&
operator()(_Pair& __x) const
@@ -508,8 +516,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
};
template<typename _Pair>
- struct _Select2nd : public unary_function<_Pair,
- typename _Pair::second_type>
+ struct _Select2nd
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+ : public unary_function<_Pair, typename _Pair::second_type>
+#endif
{
typename _Pair::second_type&
operator()(_Pair& __x) const
diff --git a/libstdc++-v3/include/ext/functional b/libstdc++-v3/include/ext/functional
index 85b944bf61d..f8402c16dc6 100644
--- a/libstdc++-v3/include/ext/functional
+++ b/libstdc++-v3/include/ext/functional
@@ -1,6 +1,6 @@
// Functional extensions -*- C++ -*-
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
+// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -183,7 +183,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @addtogroup SGIextensions
*/
template <class _Tp>
- struct identity : public std::_Identity<_Tp> {};
+ struct identity
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ : public std::unary_function<_Tp,_Tp>,
+ public std::_Identity<_Tp> {};
+#else
+ : public std::_Identity<_Tp> {};
+#endif
/** @c select1st and @c select2nd are extensions provided by SGI. Their
* @c operator()s
@@ -197,11 +203,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
/// An \link SGIextensions SGI extension \endlink.
template <class _Pair>
- struct select1st : public std::_Select1st<_Pair> {};
+ struct select1st
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ : public std::unary_function<_Pair, typename _Pair::first_type>,
+ public std::_Select1st<_Pair> {};
+#else
+ : public std::_Select1st<_Pair> {};
+#endif
/// An \link SGIextensions SGI extension \endlink.
template <class _Pair>
- struct select2nd : public std::_Select2nd<_Pair> {};
+ struct select2nd
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ : public std::unary_function<_Pair, typename _Pair::second_type>,
+ public std::_Select2nd<_Pair> {};
+#else
+ : public std::_Select2nd<_Pair> {};
+#endif
/** @} */
// extension documented next
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/52942.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/52942.cc
new file mode 100644
index 00000000000..bf05fab0d28
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/52942.cc
@@ -0,0 +1,37 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+
+// Copyright (C) 2012 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 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without Pred 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <unordered_map>
+#include <functional>
+
+struct TFoo {};
+
+struct TFoo_hash
+{
+ std::size_t operator()(const TFoo &) const { return 0; }
+};
+
+void f1(std::unordered_map<TFoo, int, TFoo_hash> &) {}
+
+void f2()
+{
+ std::unordered_map<TFoo, int, TFoo_hash> map1;
+ std::bind(f1, std::ref(map1));
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/52942.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/52942.cc
new file mode 100644
index 00000000000..067e57a5e26
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/52942.cc
@@ -0,0 +1,37 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+
+// Copyright (C) 2012 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 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without Pred 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <unordered_set>
+#include <functional>
+
+struct TFoo {};
+
+struct TFoo_hash
+{
+ std::size_t operator()(const TFoo &) const { return 0; }
+};
+
+void f1(std::unordered_set<TFoo, TFoo_hash> &) {}
+
+void f2()
+{
+ std::unordered_set<TFoo, TFoo_hash> set1;
+ std::bind(f1, std::ref(set1));
+}