diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 58148f0d47a3..19033242f7eb 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,16 @@ +2009-10-29 Paolo Carlini + + 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 + + PR libstdc++/40925 + * testsuite/20_util/pair/40925.cc: Add. + 2009-10-29 Paolo Carlini * include/decimal/decimal: Minor formatting and uglification fixes. diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index d6c590186d65..0e153d3e7fd8 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -60,6 +60,10 @@ #include // for std::move / std::forward, std::decay, and // std::swap +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +#include +#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 - pair(_U1&& __x, _U2&& __y) + pair(_U1&& __x, _U2&& __y, typename + std::enable_if::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 - 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 000000000000..d4907231c7e3 --- /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 +// . + +// 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 + +struct X +{ + explicit X(int, int) { } + +private: + X(const X&) = delete; +}; + +// libstdc++/40925 +void test01() +{ + int *ip = 0; + int X::*mp = 0; + + std::pair p1(0, 0); + std::pair p2(ip, 0); + std::pair p3(0, ip); + std::pair p4(ip, ip); + + std::pair p5(0, 0); + std::pair p6(mp, 0); + std::pair p7(0, mp); + std::pair p8(mp, mp); +}