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

Is it an unclear wording about deducing template arguments for function parameter pack #4066

Open
xmh0511 opened this issue Jul 1, 2020 · 0 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jul 1, 2020

template<typename...T>
void func(T...args){
}
int main(){
  func(1,2.0,'c');
}

Consider the above code, there's a rule that applied to it to deduce these template arguments for this function template (call). It is:
temp.deduct.call#1

For a function parameter pack that occurs at the end of the parameter-declaration-list, deduction is performed for each remaining argument of the call, taking the type P of the declarator-id of the function parameter pack as the corresponding function template parameter type. Each deduction deduces template arguments for subsequent positions in the template parameter packs expanded by the function parameter pack.

That means for the parameter-declaration T...args, it declares a function template park, hence the function parameter type that is used to against the type of function argument is T because ...args is the declarator-id of this declaration. So, for this function call func(1,2.0,'c'), template parameter pack T would be the set consists of {int,double,char}.

However, consider the following variant:

template<typename...T>
void func(T...){
}
int main(){
  func(1,2.0,'c');
}

There's no declarator-id here, just an abstract-declarator that denote the ..., How would the quote be applied to this case? What's the corresponding function parameter type here? How to form this parameter type? Is it a defect for this case when draft the standard?

@xmh0511 xmh0511 changed the title Is it a unclear about deducing template arguments for function parameter pack Is it an unclear wording about deducing template arguments for function parameter pack Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant