Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[temp.deduct.call] Clear up wording regarding function parameter packs appearing in non-deduced contexts #3900

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sdkrystian
Copy link
Contributor

CWG 1388 and CWG 1399 were both resolved by the resolution for CWG 1388, however the wording doesn't account for patterns that don't solely consist of a template parameter pack, or include other template parameters that are otherwise deductible. This PR clears this up, and explicitly specifies that such template parameter pack are never deduced, even if they appear in a deduced context elsewhere.

This is borderline editorial, but I believe the defects and accompanying notes on the wiki sufficiently express the intended meaning here.

@sdkrystian
Copy link
Contributor Author

Here's an example: https://godbolt.org/z/vMgAZL

context\iref{temp.deduct.type}, the type of that pack is
never deduced.
context\iref{temp.deduct.type}, the template parameter pack(s)
expanded by that pack are never deduced, even if they appear in a deduced context elsewhere.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new wording seems confusing: packs are expanded by pack expansions, not by packs. Replacing "that pack" with "that function parameter pack" would help. Also, "(s)" -> "s", please.

Is it clear that the "even if" part is the intent? This seems ambiguous.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... not only ambiguous, but inconsistent with unanimous implementation practice: https://godbolt.org/z/78TjoY

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, it seems the current wording is suitable for either case.

If a template parameter is used only in non-deduced contexts and is not explicitly specified, template argument deduction fails.

When a function parameter pack appears in a non-deduced context ([temp.deduct.type]), the type of that pack is never deduced.

  1. Template parameter that appears in non-deduced context does not participate in template argument deduction
  2. These template parameters that only appear in non-deduced context should be explicitly specified their template arguments, otherwise, the deduction fails.

In addition, except that [temp.deduct.call#1] explicitly says that

When a function parameter pack appears in a non-deduced context ([temp.deduct.type]), the type of that pack is never deduced.

It seems that the other kinds of argument deduction do not strong this concept, that is

any template parameter that appears in a non-deduced context is never deduced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested Changes to the wording or approach have been requested and not yet applied.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants