[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: |
Óscar Fuentes |
Subject: |
bug#23610: 25.0.94; c++-mode doesn't fontify typename... like typename |
Date: |
Mon, 30 May 2016 15:49:57 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux) |
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"?
Neiter, 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':
template <typename ... Ts> struct Foo {
void print() {
printf("Intantiated 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