From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32034 invoked by alias); 17 Aug 2014 02:28:04 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 31432 invoked by uid 89); 17 Aug 2014 02:27:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=BAYES_00,MISSING_MID,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: filter01.roch.ny.frontiernet.net Received: from filter01.roch.ny.frontiernet.net (HELO filter01.roch.ny.frontiernet.net) (66.133.183.226) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 17 Aug 2014 02:27:54 +0000 Received: from localhost (localhost [127.0.0.1]) by filter01.roch.ny.frontiernet.net (Postfix) with ESMTP id 6938510498A; Sun, 17 Aug 2014 02:27:52 +0000 (UTC) Received: from relay03.roch.ny.frontiernet.net ([66.133.182.166]) by localhost (filter01.roch.ny.frontiernet.net [66.133.183.226]) (amavisd-new, port 10024) with LMTP id sJzyBBpWSkbg; Sun, 17 Aug 2014 02:27:40 +0000 (UTC) X-Previous-IP: 50.49.151.53 Received: from HOME.frontiernet.net (unknown [50.49.151.53]) by relay03.roch.ny.frontiernet.net (Postfix) with ESMTPA id A158023B49; Sun, 17 Aug 2014 02:27:34 +0000 (UTC) Date: Sun, 17 Aug 2014 02:28:00 -0000 To: gcc-help@gcc.gnu.org From: Sidney Marshall Subject: Re: C++11 - Parameter pack question Cc: Sidney Marshall ,gcc-help@gcc.gnu.org In-Reply-To: References: <201408160114.s7G1EKDO087976@nef2.ens.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1"; format=flowed Content-Transfer-Encoding: quoted-printable X-SW-Source: 2014-08/txt/msg00115.txt.bz2 Message-ID: <20140817022800.EnEUlM9OEeuW6kg-ASqAmphy78V9uUBJVbN32SmcSxk@z> At 09:12 AM 8/16/2014 +0200, Marc Glisse wrote: >On Fri, 15 Aug 2014, Sidney Marshall wrote: > >>The following code compiles and runs correctly but gives a warning: >> >>---------------------------------------- >>#include >> >>using namespace std; >> >>template >>T sum(T value) { >> return value; >>} >> >>template >>auto sum(T value, U ... values) { >> return value + sum(values ...); >>} >> >>int main() { >> cout << sum(1, 2, 4.6) << endl; >> cout << sum(1, "abcde", 2) << endl; >>} >>-------------------------------------- >> >>$ g++ -std=3Dc++11 pack.cpp >>pack.cpp:11:31: warning: =E2??sum=E2?? function=20 >>uses =E2??auto=E2?? type specifier without trailing=20 >>return type [enabled by default] >>auto sum(T value, U ... values) { > >The warning should probably specify that this is=20 >a C++14 feature. You should be compiling with -std=3Dc++1y. You are correct - I didn't read section 7.1.6.4=20 paragraphs 2 and 5 of the standard correctly. Thank you. I guess I can't write this function in C++11 this way. >-- >Marc Glisse --Sidney Marshall