bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23610: 25.0.94; c++-mode doesn't fontify typename... like typename


From: Alan Mackenzie
Subject: bug#23610: 25.0.94; c++-mode doesn't fontify typename... like typename
Date: Mon, 30 May 2016 15:25:39 +0000
User-agent: Mutt/1.5.24 (2015-08-30)

Hello, Óscar.

Thanks for your post!

On Mon, May 30, 2016 at 03:49:57PM +0200, Óscar Fuentes wrote:
> Hello Alan.

> Alan Mackenzie <acm@muc.de> writes:

> > I'm not all that familiar with variadic templates.  In the declaration
> > below, is the "..." token syntactically part of "typename..." or is
> > better regarded as part of "... Y"?

> Neither, I'll say.

> It is legal to omit the name of the parameter pack (the `Y' in the
> example).

> > I also need to get a feel for what keywords can come before the "...".
> > Obviously "typename", but what about things like "class"?

> Yes, `class' and `typename' are interchangeable here. There is also
> `sizeof':

I thought there might be something like that.  ;-)

> template <typename ... Ts> struct Foo {
>   void print() {
>     printf("Instantiated with %d parameters.\n", sizeof...(Ts));
>   }
> };

> int main() {
>   Foo<int, double> foo;
>   foo.print();
>   return 0;
> }


> Prints

> Intantiated with 2 parameters.


> > Do you know of a good web page where these things are explained
> > completely and concisely, yet readably?  If so, please tell me!

> Try this, which is short and precise:

> http://en.cppreference.com/w/cpp/language/parameter_pack

That looks like exactly what I need.  Thanks very much!

-- 
Alan Mackenzie (Nuremberg, Germany).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]