And yes, -ENOPATCH.
On 4 April 2016 at 21:42, Ville Voutilainen <ville.voutilai...@gmail.com> wrote: > Tested on Linux-PPC64. > > 2016-04-04 Ville Voutilainen <ville.voutilai...@gmail.com> > > PR libstdc++/70437 > * include/bits/stl_pair.h (_ConstructiblePair, > _ImplicitlyConvertiblePair, _MoveConstructiblePair, > _ImplicitlyMoveConvertiblePair): Add shortcut conditions > for same-type cases. > * testsuite/20_util/pair/70437.cc: New.
diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index 7057030..206553a 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -90,29 +90,45 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template <typename _T1, typename _T2, typename _U1, typename _U2> constexpr bool _ConstructiblePair() { - return __and_<is_constructible<_T1, const _U1&>, - is_constructible<_T2, const _U2&>>::value; + return __and_<__or_<is_same<typename decay<_T1>::type, + typename decay<_U1>::type>, + is_constructible<_T1, const _U1&>>, + __or_<is_same<typename decay<_T2>::type, + typename decay<_U2>::type>, + is_constructible<_T2, const _U2&>>>::value; } template <typename _T1, typename _T2, typename _U1, typename _U2> constexpr bool _ImplicitlyConvertiblePair() { - return __and_<is_convertible<const _U1&, _T1>, - is_convertible<const _U2&, _T2>>::value; + return __and_<__or_<is_same<typename decay<_T1>::type, + typename decay<_U1>::type>, + is_convertible<const _U1&, _T1>>, + __or_<is_same<typename decay<_T2>::type, + typename decay<_U2>::type>, + is_convertible<const _U2&, _T2>>>::value; } template <typename _T1, typename _T2, typename _U1, typename _U2> constexpr bool _MoveConstructiblePair() { - return __and_<is_constructible<_T1, _U1&&>, - is_constructible<_T2, _U2&&>>::value; + return __and_<__or_<is_same<typename decay<_T1>::type, + typename decay<_U1>::type>, + is_constructible<_T1, _U1&&>>, + __or_<is_same<typename decay<_T2>::type, + typename decay<_U2>::type>, + is_constructible<_T2, _U2&&>>>::value; } template <typename _T1, typename _T2, typename _U1, typename _U2> constexpr bool _ImplicitlyMoveConvertiblePair() { - return __and_<is_convertible<_U1&&, _T1>, - is_convertible<_U2&&, _T2>>::value; + return __and_<__or_<is_same<typename decay<_T1>::type, + typename decay<_U1>::type>, + is_convertible<_U1&&, _T1>>, + __or_<is_same<typename decay<_T2>::type, + typename decay<_U2>::type>, + is_convertible<_U2&&, _T2>>>::value; } diff --git a/libstdc++-v3/testsuite/20_util/pair/70437.cc b/libstdc++-v3/testsuite/20_util/pair/70437.cc new file mode 100644 index 0000000..37e6fb7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/70437.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2016 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/>. + +#include <utility> + +template <class T> struct B; + +template <class T> struct A +{ + A(A&&) = default; + A(const B<T> &); +}; + +template <class T> struct B +{ + std::pair<A<T>,int> a; + B(B&&) = default; +}; + +bool b = std::is_move_constructible<A<int> >::value;