From patchwork Fri Aug 6 14:47:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 61123 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 EA7A01007D2 for ; Sat, 7 Aug 2010 00:48:14 +1000 (EST) Received: (qmail 10013 invoked by alias); 6 Aug 2010 14:48:12 -0000 Received: (qmail 10003 invoked by uid 22791); 6 Aug 2010 14:48:10 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from rcsinet10.oracle.com (HELO rcsinet10.oracle.com) (148.87.113.121) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 06 Aug 2010 14:48:04 +0000 Received: from rcsinet13.oracle.com (rcsinet13.oracle.com [148.87.113.125]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id o76Em0HY002568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 6 Aug 2010 14:48:02 GMT Received: from acsmt353.oracle.com (acsmt353.oracle.com [141.146.40.153]) by rcsinet13.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o76Elp6Q026877 for ; Fri, 6 Aug 2010 14:47:53 GMT Received: from abhmt003.oracle.com by acsmt353.oracle.com with ESMTP id 491434201281106043; Fri, 06 Aug 2010 07:47:23 -0700 Received: from macbook-pro-di-paolo-carlini.local (/152.96.0.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 06 Aug 2010 07:47:22 -0700 Message-ID: <4C5C2074.3070904@oracle.com> Date: Fri, 06 Aug 2010 16:47:16 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; it; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 MIME-Version: 1.0 To: Gcc Patch List CC: libstdc++ Subject: [v3] Implement US 98 and US 99 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, committed to mainline. Paolo. ///////////// 2010-08-06 Paolo Carlini * include/std/tuple (pack_arguments): Rename to forward_as_tuple and simplify, per US 98 and US 99. * testsuite/20_util/tuple/creation_functions/pack_arguments.cc: Rename to... * testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc: ... this, adjust. * testsuite/20_util/pair/piecewise.cc: Adjust. Index: include/std/tuple =================================================================== --- include/std/tuple (revision 162942) +++ include/std/tuple (working copy) @@ -549,27 +549,10 @@ return __result_type(std::forward<_Elements>(__args)...); } - template::value> - struct __pa_add_rvalue_reference_helper - { typedef typename std::add_rvalue_reference<_Tp>::type __type; }; - - template - struct __pa_add_rvalue_reference_helper<_Tp, true> - { typedef _Tp& __type; }; - - template - struct __pa_add_rvalue_reference - : public __pa_add_rvalue_reference_helper<_Tp> - { }; - template - inline tuple::__type...> - pack_arguments(_Elements&&... __args) - { - typedef tuple::__type...> - __result_type; - return __result_type(std::forward<_Elements>(__args)...); - } + inline tuple<_Elements&&...> + forward_as_tuple(_Elements&&... __args) + { return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); } template struct __index_holder { }; Index: testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc =================================================================== --- testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc (revision 162940) +++ testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc (working copy) @@ -30,16 +30,16 @@ { bool test __attribute__((unused)) = true; - std::pack_arguments(); + std::forward_as_tuple(); - VERIFY( std::get<0>(std::pack_arguments(-1)) == -1 ); - VERIFY( (std::is_same(std::forward_as_tuple(-1)) == -1 ); + VERIFY( (std::is_same>::value) ); const int i1 = 1; const int i2 = 2; const double d1 = 4.0; - auto t1 = std::pack_arguments(i1, i2, d1); + auto t1 = std::forward_as_tuple(i1, i2, d1); VERIFY( (std::is_same>::value) ); VERIFY( std::get<0>(t1) == i1 ); @@ -48,7 +48,7 @@ typedef const int a_type1[3]; a_type1 a1 = { -1, 1, 2 }; - auto t2 = std::pack_arguments(a1); + auto t2 = std::forward_as_tuple(a1); VERIFY( (std::is_same>::value) ); VERIFY( std::get<0>(t2)[0] == a1[0] ); VERIFY( std::get<0>(t2)[1] == a1[1] ); @@ -57,7 +57,7 @@ typedef int a_type2[2]; a_type2 a2 = { 2, -2 }; volatile int i4 = 1; - auto t3 = std::pack_arguments(a2, i4); + auto t3 = std::forward_as_tuple(a2, i4); VERIFY( (std::is_same>::value) ); VERIFY( std::get<0>(t3)[0] == a2[0] ); Index: testsuite/20_util/tuple/creation_functions/pack_arguments.cc =================================================================== --- testsuite/20_util/tuple/creation_functions/pack_arguments.cc (revision 162940) +++ testsuite/20_util/tuple/creation_functions/pack_arguments.cc (working copy) @@ -1,72 +0,0 @@ -// { dg-options "-std=gnu++0x" } - -// 2010-04-30 Paolo Carlini -// -// Copyright (C) 2010 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 -// . - -// Tuple - -#include -#include -#include - -void -test01() -{ - bool test __attribute__((unused)) = true; - - std::pack_arguments(); - - VERIFY( std::get<0>(std::pack_arguments(-1)) == -1 ); - VERIFY( (std::is_same>::value) ); - - const int i1 = 1; - const int i2 = 2; - const double d1 = 4.0; - auto t1 = std::pack_arguments(i1, i2, d1); - VERIFY( (std::is_same>::value) ); - VERIFY( std::get<0>(t1) == i1 ); - VERIFY( std::get<1>(t1) == i2 ); - VERIFY( std::get<2>(t1) == d1 ); - - typedef const int a_type1[3]; - a_type1 a1 = { -1, 1, 2 }; - auto t2 = std::pack_arguments(a1); - VERIFY( (std::is_same>::value) ); - VERIFY( std::get<0>(t2)[0] == a1[0] ); - VERIFY( std::get<0>(t2)[1] == a1[1] ); - VERIFY( std::get<0>(t2)[2] == a1[2] ); - - typedef int a_type2[2]; - a_type2 a2 = { 2, -2 }; - volatile int i4 = 1; - auto t3 = std::pack_arguments(a2, i4); - VERIFY( (std::is_same>::value) ); - VERIFY( std::get<0>(t3)[0] == a2[0] ); - VERIFY( std::get<0>(t3)[1] == a2[1] ); - VERIFY( std::get<1>(t3) == i4 ); -} - -int main() -{ - test01(); - return 0; -} Index: testsuite/20_util/pair/piecewise.cc =================================================================== --- testsuite/20_util/pair/piecewise.cc (revision 162940) +++ testsuite/20_util/pair/piecewise.cc (working copy) @@ -70,21 +70,21 @@ bool test __attribute__((unused)) = true; std::pair pp0(std::piecewise_construct_t(), - std::pack_arguments(-3), - std::pack_arguments()); + std::forward_as_tuple(-3), + std::forward_as_tuple()); VERIFY( pp0.first.get() == -3 ); VERIFY( pp0.second.get() == 757 ); std::pair pp1(std::piecewise_construct_t(), - std::pack_arguments(6), - std::pack_arguments(5, 4)); + std::forward_as_tuple(6), + std::forward_as_tuple(5, 4)); VERIFY( pp1.first.get() == 6 ); VERIFY( pp1.second.get1() == 5 ); VERIFY( pp1.second.get2() == 4 ); std::pair pp2(std::piecewise_construct_t(), - std::pack_arguments(2, 1), - std::pack_arguments(-1, -3)); + std::forward_as_tuple(2, 1), + std::forward_as_tuple(-1, -3)); VERIFY( pp2.first.get1() == 2 ); VERIFY( pp2.first.get2() == 1 ); VERIFY( pp2.second.get1() == -1 );