public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marc Glisse <marc.glisse@inria.fr>
To: Sidney Marshall <sidneym@frontiernet.net>
Cc: gcc-help@gcc.gnu.org
Subject: Re: C++11 - Parameter pack question
Date: Sat, 16 Aug 2014 07:12:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.11.1408160907210.1729@laptop-mg.saclay.inria.fr> (raw)
In-Reply-To: <201408160114.s7G1EKDO087976@nef2.ens.fr>

On Fri, 15 Aug 2014, Sidney Marshall wrote:

> The following code compiles and runs correctly but gives a warning:
>
> ----------------------------------------
> #include<iostream>
>
> using namespace std;
>
> template<class T>
> T sum(T value) {
>  return value;
> }
>
> template<class T, class ... U>
> 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=c++11 pack.cpp
> pack.cpp:11:31: warning: â??sumâ?? function uses â??autoâ?? type specifier 
> without trailing return type [enabled by default]
> auto sum(T value, U ... values) {

The warning should probably specify that this is a C++14 feature. You 
should be compiling with -std=c++1y.

-- 
Marc Glisse

       reply	other threads:[~2014-08-16  7:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201408160114.s7G1EKDO087976@nef2.ens.fr>
2014-08-16  7:12 ` Marc Glisse [this message]
     [not found]   ` <alpine.DEB.2.11.1408160907210.1729@laptop-mg.saclay.inria. fr>
2014-08-17  2:28     ` Sidney Marshall
2014-08-17  2:28     ` Sidney Marshall
2014-08-16  1:14 Sidney Marshall
  -- strict thread matches above, loose matches on Subject: below --
2014-08-16  1:14 Sidney Marshall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.11.1408160907210.1729@laptop-mg.saclay.inria.fr \
    --to=marc.glisse@inria.fr \
    --cc=gcc-help@gcc.gnu.org \
    --cc=sidneym@frontiernet.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).