From patchwork Tue Dec 6 15:13:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 129703 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]) by ozlabs.org (Postfix) with SMTP id E37171007DF for ; Wed, 7 Dec 2011 02:14:56 +1100 (EST) Received: (qmail 27716 invoked by alias); 6 Dec 2011 15:14:47 -0000 Received: (qmail 27694 invoked by uid 22791); 6 Dec 2011 15:14:46 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rcsinet15.oracle.com (HELO rcsinet15.oracle.com) (148.87.113.117) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 06 Dec 2011 15:14:32 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by rcsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pB6FERaU001160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 6 Dec 2011 15:14:30 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id pB6FER7O020110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 6 Dec 2011 15:14:27 GMT Received: from abhmt107.oracle.com (abhmt107.oracle.com [141.146.116.59]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id pB6FEMdU009735; Tue, 6 Dec 2011 09:14:22 -0600 Received: from [192.168.1.4] (/79.53.82.215) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 06 Dec 2011 07:14:21 -0800 Message-ID: <4EDE3110.7030007@oracle.com> Date: Tue, 06 Dec 2011 16:13:20 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ Subject: [v3] libstdc++/51183 X-IsSubscribed: yes 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 Hi, tested x86_64-linux, committed. Thanks, Paolo. ///////////////////// 2011-12-06 Jonathan Wakely Chris Jefferson PR libstdc++/51183 * include/std/stl_pair.h (pair<>::__cons, pair<>::__do_cons): Remove. (pair<>::pair(piecewise_construct_t, tuple<>, tuple<>): Only declare. (pair<>::pair(tuple<>&, tuple<>&, _Index_tuple<>, _Index_tuple<>)): Declare. * include/std/tuple (pair<>::__cons, pair<>::__do_cons): Remove. (pair<>::pair(tuple<>&, tuple<>&, _Index_tuple<>, _Index_tuple<>)): Define. (pair<>::pair(piecewise_construct_t, tuple<>, tuple<>): Define, delegating to the latter. * testsuite/20_util/pair/piecewise2.cc: New. Index: include/std/tuple =================================================================== --- include/std/tuple (revision 182041) +++ include/std/tuple (working copy) @@ -1057,21 +1057,26 @@ // See stl_pair.h... template - template - inline _Tp - pair<_T1, _T2>::__cons(tuple<_Args...>&& __tuple) - { - typedef typename _Build_index_tuple::__type - _Indexes; - return __do_cons<_Tp>(std::move(__tuple), _Indexes()); - } + template + inline + pair<_T1, _T2>:: + pair(piecewise_construct_t, + tuple<_Args1...> __first, tuple<_Args2...> __second) + : pair(__first, __second, + typename _Build_index_tuple::__type(), + typename _Build_index_tuple::__type()) + { } template - template - inline _Tp - pair<_T1, _T2>::__do_cons(tuple<_Args...>&& __tuple, - const _Index_tuple<_Indexes...>&) - { return _Tp(std::forward<_Args>(get<_Indexes>(__tuple))...); } + template + inline + pair<_T1, _T2>:: + pair(tuple<_Args1...>& __tuple1, tuple<_Args2...>& __tuple2, + _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>) + : first(std::forward<_Args1>(std::get<_Indexes1>(__tuple1))...), + second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...) + { } _GLIBCXX_END_NAMESPACE_VERSION } // namespace Index: include/bits/stl_pair.h =================================================================== --- include/bits/stl_pair.h (revision 182041) +++ include/bits/stl_pair.h (working copy) @@ -149,11 +149,8 @@ : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) { } - template - pair(piecewise_construct_t, - tuple<_Args1...> __first, tuple<_Args2...> __second) - : first(__cons(std::move(__first))), - second(__cons(std::move(__second))) { } + template + pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>); pair& operator=(const pair& __p) @@ -202,13 +199,10 @@ } private: - template - static _Tp - __cons(tuple<_Args...>&&); - - template - static _Tp - __do_cons(tuple<_Args...>&&, const _Index_tuple<_Indexes...>&); + template + pair(tuple<_Args1...>&, tuple<_Args2...>&, + _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>); #endif }; Index: testsuite/20_util/pair/piecewise2.cc =================================================================== --- testsuite/20_util/pair/piecewise2.cc (revision 0) +++ testsuite/20_util/pair/piecewise2.cc (revision 0) @@ -0,0 +1,60 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 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 +#include + +struct NoCon +{ + NoCon() = delete; + NoCon(const NoCon&) = delete; +}; + +struct RefCheck1 +{ + RefCheck1(NoCon&, NoCon&&) { } + RefCheck1() = delete; + RefCheck1(const RefCheck1&) = delete; +}; + +struct RefCheck2 +{ + RefCheck2(const NoCon&, const NoCon&&, NoCon&) { } + RefCheck2() = delete; + RefCheck2(const RefCheck2&) = delete; +}; + +struct Default +{ + Default(); + Default(const Default&) = delete; +}; + +// libstdc++/51183 +void test01(std::tuple t1, + std::tuple t2) +{ + std::pair(std::piecewise_construct, t1, t2); +} + +void test02(std::tuple<> t1, std::tuple t2) +{ + std::pair A(std::piecewise_construct, t1, t2); +}