From: Jonathan Wakely Date: Sat, 6 Dec 2014 20:38:01 +0000 (+0000) Subject: re PR libstdc++/61947 (Ambiguous calls when constructing std::tuple) X-Git-Tag: releases/gcc-4.8.4~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=650b975cf687f1a39efab428517b4bad101664f9;p=thirdparty%2Fgcc.git re PR libstdc++/61947 (Ambiguous calls when constructing std::tuple) PR libstdc++/61947 * include/std/tuple (_Head_base): Use allocator_arg_t parameters to disambiguate unary constructors. (_Tuple_impl): Pass allocator_arg_t arguments. * testsuite/20_util/tuple/61947.cc: New. * testsuite/20_util/uses_allocator/cons_neg.cc: Adjust dg-error line. From-SVN: r218453 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index bf2d3bb473cc..de13b7cebd73 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -8,6 +8,13 @@ * testsuite/20_util/function/63840.cc: New. * testsuite/tr1/3_function_objects/function/63840.cc: New. + PR libstdc++/61947 + * include/std/tuple (_Head_base): Use allocator_arg_t parameters to + disambiguate unary constructors. + (_Tuple_impl): Pass allocator_arg_t arguments. + * testsuite/20_util/tuple/61947.cc: New. + * testsuite/20_util/uses_allocator/cons_neg.cc: Adjust dg-error line. + 2014-11-27 Thomas Preud'homme Backport from mainline diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 9ab30e514558..de85fbbcd45c 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -88,21 +88,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr _Head_base(const _Head& __h) : _Head(__h) { } - template::value>::type> + constexpr _Head_base(const _Head_base&) = default; + constexpr _Head_base(_Head_base&&) = default; + + template constexpr _Head_base(_UHead&& __h) : _Head(std::forward<_UHead>(__h)) { } - _Head_base(__uses_alloc0) + _Head_base(allocator_arg_t, __uses_alloc0) : _Head() { } template - _Head_base(__uses_alloc1<_Alloc> __a) + _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a) : _Head(allocator_arg, *__a._M_a) { } template - _Head_base(__uses_alloc2<_Alloc> __a) + _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a) : _Head(*__a._M_a) { } template @@ -133,21 +134,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr _Head_base(const _Head& __h) : _M_head_impl(__h) { } - template::value>::type> + constexpr _Head_base(const _Head_base&) = default; + constexpr _Head_base(_Head_base&&) = default; + + template constexpr _Head_base(_UHead&& __h) : _M_head_impl(std::forward<_UHead>(__h)) { } - _Head_base(__uses_alloc0) + _Head_base(allocator_arg_t, __uses_alloc0) : _M_head_impl() { } template - _Head_base(__uses_alloc1<_Alloc> __a) + _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a) : _M_head_impl(allocator_arg, *__a._M_a) { } template - _Head_base(__uses_alloc2<_Alloc> __a) + _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a) : _M_head_impl(*__a._M_a) { } template @@ -285,7 +287,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a) : _Inherited(__tag, __a), - _Base(__use_alloc<_Head>(__a)) { } + _Base(__tag, __use_alloc<_Head>(__a)) { } template _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, diff --git a/libstdc++-v3/testsuite/20_util/tuple/61947.cc b/libstdc++-v3/testsuite/20_util/tuple/61947.cc new file mode 100644 index 000000000000..7e77de657a1a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/61947.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2014 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 +// . + +#include + +struct ConvertibleToAny { + template operator T() const { return T(); } +}; + +int main() { + std::tuple t(ConvertibleToAny{}); +} diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc index e5f015fa146c..282e33d6fc16 100644 --- a/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc +++ b/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc @@ -44,4 +44,4 @@ void test01() tuple t(allocator_arg, a, 1); } -// { dg-error "no matching function" "" { target *-*-* } 118 } +// { dg-error "no matching function" "" { target *-*-* } 119 }