From: Ville Voutilainen Date: Mon, 19 Dec 2016 15:22:05 +0000 (+0200) Subject: backport: Make the perfect-forwarding constructor of a two-element tuple sfinae away... X-Git-Tag: releases/gcc-5.5.0~633 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83c65d6de8460954f00d719f299a3e4b3f1a366f;p=thirdparty%2Fgcc.git backport: Make the perfect-forwarding constructor of a two-element tuple sfinae away when the first argument is an allocator_arg. Backport from mainline 2016-12-19 Ville Voutilainen Make the perfect-forwarding constructor of a two-element tuple sfinae away when the first argument is an allocator_arg. * include/std/tuple (tuple(_U1&&, _U2&&)): Constrain. * testsuite/20_util/tuple/cons/allocator_with_any.cc: New. From-SVN: r243797 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8dbed86fd647..c56ff11ba5bf 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2016-12-19 Ville Voutilainen + + Backport from mainline + 2016-12-19 Ville Voutilainen + + Make the perfect-forwarding constructor of a two-element tuple + sfinae away when the first argument is an allocator_arg. + * include/std/tuple (tuple(_U1&&, _U2&&)): Constrain. + * testsuite/20_util/tuple/cons/allocator_with_any.cc: New. + 2016-12-13 Jonathan Wakely Backport from mainline diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index e500a762d876..90a0d73c58b6 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -607,7 +607,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template, - is_convertible<_U2, _T2>>::value>::type> + is_convertible<_U2, _T2>, + __not_::type, + allocator_arg_t>>> + ::value>::type> explicit constexpr tuple(_U1&& __a1, _U2&& __a2) : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { } diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/allocator_with_any.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/allocator_with_any.cc new file mode 100644 index 000000000000..dd9a06603ae2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/allocator_with_any.cc @@ -0,0 +1,42 @@ +// { dg-do run } +// { dg-options "-std=gnu++14" } +// 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 +// . + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on tuple. If the implementation changed +// this test may begin to fail. + +#include +#include +#include + +using std::experimental::any; + +void test01() +{ + std::tuple t(std::allocator_arg, + std::allocator{}); + VERIFY(std::get<0>(t).empty()); + VERIFY(std::get<1>(t).empty()); +} + +int main() +{ + test01(); +}