From patchwork Tue May 24 16:35:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ville Voutilainen X-Patchwork-Id: 625733 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rDgyc21tgz9ssM for ; Wed, 25 May 2016 02:36:07 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=DIQInAtA; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:content-type; q=dns; s=default; b=XAiCWQZdYUiZ1p0bd3SZC K2d35ty439Vr4tOg1EfbH7SHj5CeO6IB4i4yQij/M/RuQB6TpYwYa+d4piPpLOMG c2qUD3hPVU+a7zTJPR/8s0i6WTZejyLqlAVDIsoy002jUiyTYu99aG2mXbvtOtxD zho/kev3IMZwlxLXqQS79M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:content-type; s=default; bh=E2okeSdtq/iK3aVinzT7ry0Htfg =; b=DIQInAtASkUNEzv0XQi4z6PuGoQ0OkLz3dryPNqJMqcLk9iWfgy6MxNyPiS w4mVixweHUkmNRy12TAC0nQDLex+5XRoz9ULaKD+7s4Ao3dLeBDX1pVtx/kZ2N/6 Lp8ukyR7gyM14dMAPINuZ4M5Rm+eOZNaG/NrJcPz9k1CaPsA= Received: (qmail 65585 invoked by alias); 24 May 2016 16:36:01 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 65567 invoked by uid 89); 24 May 2016 16:36:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=6789, _tuple_impl, _alloc, __in X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-vk0-f48.google.com Received: from mail-vk0-f48.google.com (HELO mail-vk0-f48.google.com) (209.85.213.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 24 May 2016 16:35:50 +0000 Received: by mail-vk0-f48.google.com with SMTP id c189so29279063vkb.1; Tue, 24 May 2016 09:35:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=7yO2KXnM6n61mbG+GCMCD6FK781O2CNN2NuXMQmwGxo=; b=LHXpN2hQM/4IgGvHgdiue0LEpm3jm9s6O9REtDks6YhXBcfbz79ChIiRIGCClWx51y NHk5bmKgWxaMdW/8B2hnstMmKuwW1QvP/4WQYuwERuCBibNuOityxwApYdlrY86516Dc AbPoticwGlHY7VmmuxmaJ2WAyM4YjD/iorzBUSvpbGJe4MJQ/WnyJCWJM3YH+GrptV/I 4CnOKR1MMyNb5jRJT7uK0rAbTaVn4ILmgALqFG3BpaWaWDK3q1i9og0DBKvoDtDZO0bz xIQKuESyzB1X/hZmwl0ZCgi5lbhXKlsDR5lksi4ut5aI0sG70Y8sfKOeDgg0PEgNEQzs Icxg== X-Gm-Message-State: ALyK8tJaxJVlqpvjjW2UCE0M8l61dVA6590Z2xNkXn7HyOoJojzxkzQKRS27PO2nbsxd67Y4KNinnez0ATftvg== MIME-Version: 1.0 X-Received: by 10.159.40.9 with SMTP id c9mr2957941uac.141.1464107748011; Tue, 24 May 2016 09:35:48 -0700 (PDT) Received: by 10.103.126.194 with HTTP; Tue, 24 May 2016 09:35:47 -0700 (PDT) In-Reply-To: References: Date: Tue, 24 May 2016 19:35:47 +0300 Message-ID: Subject: Re: [v3 PATCH] PR libstdc++/66338 From: Ville Voutilainen To: "libstdc++" , "gcc-patches@gcc.gnu.org" On 24 May 2016 at 17:59, Ville Voutilainen wrote: Slight tweak. The avoidance of _NotSameTuple wasn't quite correct for the templates that take const tuple<_UElements...>& or tuple<_UElements...>&& instead of const _UElements&... or _UElements&&... This patch introduces a new helper alias to cover those cases and takes it into use where appropriate. All tests pass, but I don't have any sane tests to verify this tweak. 2016-05-24 Ville Voutilainen PR libstdc++/66338 * include/std/tuple (_TMC): Add a check for _NotSameTuple. * include/std/tuple (tuple(_UElements&&...)): Remove the separate check for _NotSameTuple. * include/std/tuple (_TMCT): New. * include/std/tuple (tuple(const tuple<_UElements...>&)): Use it. * include/std/tuple (tuple(tuple<_UElements...>&&)): Likewise. * include/std/tuple (tuple(allocator_arg_t, const _Alloc&, const tuple<_UElements...>&)): Likewise. * include/std/tuple (tuple(allocator_arg_t, const _Alloc&, tuple<_UElements...>&&)): Likewise. * testsuite/20_util/tuple/cons/66338.cc: New. diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 7522e43..4de36e5 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -620,14 +620,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Shortcut for the cases where constructors taking _UElements... // need to be constrained. template using _TMC = - _TC<(sizeof...(_Elements) == sizeof...(_UElements)), + _TC<(sizeof...(_Elements) == sizeof...(_UElements)) + && (_TC<(sizeof...(_UElements)==1), _Elements...>:: + template _NotSameTuple<_UElements...>()), + _Elements...>; + + // Shortcut for the cases where constructors taking tuple<_UElements...> + // need to be constrained. + template using _TMCT = + _TC<(sizeof...(_Elements) == sizeof...(_UElements)) + && (_TC:: + template _NotSameTuple>()), _Elements...>; template::template - _NotSameTuple<_UElements...>() - && _TMC<_UElements...>::template + _TMC<_UElements...>::template _MoveConstructibleTuple<_UElements...>() && _TMC<_UElements...>::template _ImplicitlyMoveConvertibleTuple<_UElements...>() @@ -638,9 +646,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template::template - _NotSameTuple<_UElements...>() - && _TMC<_UElements...>::template + _TMC<_UElements...>::template _MoveConstructibleTuple<_UElements...>() && !_TMC<_UElements...>::template _ImplicitlyMoveConvertibleTuple<_UElements...>() @@ -660,9 +666,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Elements...>; template::template + enable_if<_TMCT<_UElements...>::template _ConstructibleTuple<_UElements...>() - && _TMC<_UElements...>::template + && _TMCT<_UElements...>::template _ImplicitlyConvertibleTuple<_UElements...>() && _TNTC<_Dummy>::template _NonNestedTuple&>(), @@ -672,9 +678,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { } template::template + enable_if<_TMCT<_UElements...>::template _ConstructibleTuple<_UElements...>() - && !_TMC<_UElements...>::template + && !_TMCT<_UElements...>::template _ImplicitlyConvertibleTuple<_UElements...>() && _TNTC<_Dummy>::template _NonNestedTuple&>(), @@ -684,9 +690,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { } template::template + enable_if<_TMCT<_UElements...>::template _MoveConstructibleTuple<_UElements...>() - && _TMC<_UElements...>::template + && _TMCT<_UElements...>::template _ImplicitlyMoveConvertibleTuple<_UElements...>() && _TNTC<_Dummy>::template _NonNestedTuple&&>(), @@ -695,9 +701,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { } template::template + enable_if<_TMCT<_UElements...>::template _MoveConstructibleTuple<_UElements...>() - && !_TMC<_UElements...>::template + && !_TMCT<_UElements...>::template _ImplicitlyMoveConvertibleTuple<_UElements...>() && _TNTC<_Dummy>::template _NonNestedTuple&&>(), @@ -764,9 +770,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { } template::template + enable_if<_TMCT<_UElements...>::template _ConstructibleTuple<_UElements...>() - && _TMC<_UElements...>::template + && _TMCT<_UElements...>::template _ImplicitlyConvertibleTuple<_UElements...>(), bool>::type=true> tuple(allocator_arg_t __tag, const _Alloc& __a, @@ -776,9 +782,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { } template::template + enable_if<_TMCT<_UElements...>::template _ConstructibleTuple<_UElements...>() - && !_TMC<_UElements...>::template + && !_TMCT<_UElements...>::template _ImplicitlyConvertibleTuple<_UElements...>(), bool>::type=false> explicit tuple(allocator_arg_t __tag, const _Alloc& __a, @@ -788,9 +794,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { } template::template + enable_if<_TMCT<_UElements...>::template _MoveConstructibleTuple<_UElements...>() - && _TMC<_UElements...>::template + && _TMCT<_UElements...>::template _ImplicitlyMoveConvertibleTuple<_UElements...>(), bool>::type=true> tuple(allocator_arg_t __tag, const _Alloc& __a, @@ -800,9 +806,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { } template::template + enable_if<_TMCT<_UElements...>::template _MoveConstructibleTuple<_UElements...>() - && !_TMC<_UElements...>::template + && !_TMCT<_UElements...>::template _ImplicitlyMoveConvertibleTuple<_UElements...>(), bool>::type=false> explicit tuple(allocator_arg_t __tag, const _Alloc& __a, diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/66338.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/66338.cc new file mode 100644 index 0000000..f57eae9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/66338.cc @@ -0,0 +1,35 @@ +// 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 +// . + +#include + +struct S { + int i_; + + template + S(T&& i) + noexcept(noexcept(i_ = i)) + { i_ = i; } + + S() noexcept : i_{0} {}; +}; + +int main() +{ + std::tuple(std::forward_as_tuple(S{})); + return 0; +}