Skip to content

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

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/templates.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7881,8 +7881,8 @@
Each deduction deduces template arguments for subsequent positions in
the template parameter packs expanded by the function parameter pack.
When a function parameter pack appears in a non-deduced
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

\begin{example}
\begin{codeblock}
template<class ... Types> void f(Types& ...);
Expand Down