Reputation: 2321
14.5.3 [temp.variadic], paragraph 5
For the purpose of determining whether a parameter pack satisfies a rule regarding entities other than parameter packs, the parameter pack is considered to be the entity that would result from an instantiation of the pattern in which it appears. [Example:
template<class ... Types> void f(Types ... rest); template<class ... Types> void g(Types ... rest) { f(&rest ...); // “&rest ...” is a pack expansion; “&rest” is its pattern }
—end example]
The committee gave the title of entity to a parameter pack, so that a lambda expression can find the identifier of it without explicitly capturing it — see this. That being said, I expected to see as an example something relevant to a lambda expression making use of a parameter pack, but the actual one is far from my expectation. I don't see how the example above is related to the wording (I think it should be about name lookup or something). Furthermore, what's the purpose of the bold text next to "the entity" (I barely understand what it means...)?
Upvotes: 0
Views: 64
Reputation: 303157
I would consider this a [minor] editorial problem in the standard (I submitted an issue about it). The text in question is a result of core issue 1662, which suggested adding that text at the end of paragraph 4, in which case the entire text would read:
A pack expansion consists of a pattern and an ellipsis, the instantiation of which produces zero or more instantiations of the pattern in a list (described below). The form of the pattern depends on the context in which the expansion occurs. Pack expansions can occur in the following contexts:
— In a function parameter pack [...]
— In a template parameter pack [...]
[...]
— In a fold-expression [...]
For the purpose of determining whether a parameter pack satisfies a rule regarding entities other than parameter packs, the parameter pack is considered to be the entity that would result from an instantiation of the pattern in which it appears.[Example:template<class ... Types> void f(Types ... rest); template<class ... Types> void g(Types ... rest) { f(&rest ...); // “&rest ...” is a pack expansion; “&rest” is its pattern }
-end example]
The example here is simply an example of a pack expansion - which is the term introduced in the previous paragraph. The fact that the "For the purpose of..." section has become its own paragraph, rather than an extension of paragraph 4, makes the placement of the example pretty odd.
That said, examples aren't normative anyway and what's important is the text.
Upvotes: 2
Reputation: 179917
What the standard tries to say here is that certain rules do not apply to a parameter pack, but do apply to the results of unpacking said pack.
E.g. to determine whether a given lambda capture is a simple-capture, you can't check whether the pack has automatic storage duration. Packs don't have storage duration. Instead, unpack the pack, and then for each unpacked result, determine whether that has automatic storage duration.
Upvotes: 1