aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <paolo@gcc.gnu.org>2009-10-29 19:26:04 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2009-10-29 19:26:04 +0000
commitd858307d7b08e7d948bb97f1e1d9c2ee109fb097 (patch)
tree2ab0b95ff993433452e04ec6c71d05d9be1d0351 /libstdc++-v3
parent486024b158a3445f48aea91fb136dde3a174d219 (diff)
downloadgcc-d858307d7b08e7d948bb97f1e1d9c2ee109fb097.zip
gcc-d858307d7b08e7d948bb97f1e1d9c2ee109fb097.tar.gz
gcc-d858307d7b08e7d948bb97f1e1d9c2ee109fb097.tar.bz2
[multiple changes]
2009-10-29 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/40925 * include/bits/stl_pair.h (pair<_T1, _T2>::pair(_U1&&, _U2&&)): Use enable_if to remove it from the overload set when either _U1 is not convertible to _T1 or _U2 is not convertible to _T2. (pair<>::pair(_U1&&, _Arg0&&, _Args&&...)): Remove. 2009-10-29 Douglas Gregor <doug.gregor@gmail.com> PR libstdc++/40925 * testsuite/20_util/pair/40925.cc: Add. From-SVN: r153725
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog13
-rw-r--r--libstdc++-v3/include/bits/stl_pair.h15
-rw-r--r--libstdc++-v3/testsuite/20_util/pair/40925.cc50
3 files changed, 70 insertions, 8 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 58148f0..1903324 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,18 @@
2009-10-29 Paolo Carlini <paolo.carlini@oracle.com>
+ PR libstdc++/40925
+ * include/bits/stl_pair.h (pair<_T1, _T2>::pair(_U1&&, _U2&&)):
+ Use enable_if to remove it from the overload set when either _U1
+ is not convertible to _T1 or _U2 is not convertible to _T2.
+ (pair<>::pair(_U1&&, _Arg0&&, _Args&&...)): Remove.
+
+2009-10-29 Douglas Gregor <doug.gregor@gmail.com>
+
+ PR libstdc++/40925
+ * testsuite/20_util/pair/40925.cc: Add.
+
+2009-10-29 Paolo Carlini <paolo.carlini@oracle.com>
+
* include/decimal/decimal: Minor formatting and uglification fixes.
* include/decimal/decimal.h: Likewise.
diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h
index d6c5901..0e153d3 100644
--- a/libstdc++-v3/include/bits/stl_pair.h
+++ b/libstdc++-v3/include/bits/stl_pair.h
@@ -60,6 +60,10 @@
#include <bits/move.h> // for std::move / std::forward, std::decay, and
// std::swap
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+#include <type_traits>
+#endif
+
_GLIBCXX_BEGIN_NAMESPACE(std)
/// pair holds two objects of arbitrary type.
@@ -85,7 +89,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<class _U1, class _U2>
- pair(_U1&& __x, _U2&& __y)
+ pair(_U1&& __x, _U2&& __y, typename
+ std::enable_if<std::is_convertible<_U1, _T1>::value
+ && std::is_convertible<_U2, _T2>::value>::type* = 0)
: first(std::forward<_U1>(__x)),
second(std::forward<_U2>(__y)) { }
@@ -106,13 +112,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
: first(std::move(__p.first)),
second(std::move(__p.second)) { }
- // http://gcc.gnu.org/ml/libstdc++/2007-08/msg00052.html
- template<class _U1, class _Arg0, class... _Args>
- pair(_U1&& __x, _Arg0&& __arg0, _Args&&... __args)
- : first(std::forward<_U1>(__x)),
- second(std::forward<_Arg0>(__arg0),
- std::forward<_Args>(__args)...) { }
-
pair&
operator=(pair&& __p)
{
diff --git a/libstdc++-v3/testsuite/20_util/pair/40925.cc b/libstdc++-v3/testsuite/20_util/pair/40925.cc
new file mode 100644
index 0000000..d490723
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/40925.cc
@@ -0,0 +1,50 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2009 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 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// NOTE: This makes use of the fact that we know how moveable
+// is implemented on pair, and also vector. If the implementation
+// changes this test may begin to fail.
+
+#include <utility>
+
+struct X
+{
+ explicit X(int, int) { }
+
+private:
+ X(const X&) = delete;
+};
+
+// libstdc++/40925
+void test01()
+{
+ int *ip = 0;
+ int X::*mp = 0;
+
+ std::pair<int*, int*> p1(0, 0);
+ std::pair<int*, int*> p2(ip, 0);
+ std::pair<int*, int*> p3(0, ip);
+ std::pair<int*, int*> p4(ip, ip);
+
+ std::pair<int X::*, int*> p5(0, 0);
+ std::pair<int X::*, int X::*> p6(mp, 0);
+ std::pair<int X::*, int X::*> p7(0, mp);
+ std::pair<int X::*, int X::*> p8(mp, mp);
+}