cplusplus / cplusplus/draft

Template parameter pack that does not participate in template argument deduction

Open
#4,555 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cwg not-editorial
Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

According to [temp.deduct.call]

Template argument deduction is done by comparing each function template parameter type (call it P) that contains template-parameters that participate in template argument deduction with the type of the corresponding argument of the call (call it A) as described below.

In most cases, the types, templates, and non-type values that are used to compose P participate in template argument deduction.

In this example

template<class...T, class U>
void fun(U);
int main(){
   fun(0);  //#1
}

As per the above rule, the template parameter pack does not participate in template argument deduction. If there were no other special rule specified, as per

if any template argument remains neither deduced nor explicitly specified, template argument deduction fails.

The deduction would fail since the template argument for the template parameter pack is neither deduced(the pack does not participate in the deduction process) nor explicitly specified.

However, in the older standard, there's a special rule states that:

A trailing template parameter pack ([temp.variadic]) not otherwise deduced will be deduced as an empty sequence of template arguments.

However, such a normative rule has become a note in the current draft. I think such a rule should be a normative rule since there's no other alternative rule that states similar things. Making it to be a note is not persuasive to explain why can #1 be otherwise deduced successfully.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the [temp.deduct.call] wording, the note linked from [temp.arg.explicit], and the example involving template<class...T, class U> void fun(U). Determine how the trailing, otherwise-undeduced pack is specified and update the draft so the successful deduction in #1 has a clear normative basis.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.