[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
This commit is contained in:
Paolo Carlini 2009-10-29 19:26:04 +00:00
parent 486024b158
commit d858307d7b
3 changed files with 70 additions and 8 deletions

View File

@ -1,3 +1,16 @@
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.

View File

@ -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)
{

View File

@ -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);
}