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] p1 The comment for a function parameter pack is conflict #5340

Open
xmh0511 opened this issue Mar 15, 2022 · 0 comments
Open

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Mar 15, 2022

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.

The formal example after this rule:

template<class T1, class ... Types> void g1(Types ..., T1);
g1(x, y, z);                  // error: Types is not deduced

However, we have implied that a template parameter pack can accept zero arguments and be deduced an empty sequence of template arguments in [temp.arg.explicit] p4

[Note 1: A trailing template parameter pack ([temp.variadic]) not otherwise deduced will be deduced as an empty sequence of template arguments. — end note]

That is, it also does not matter if Types is not deduced. I think the real reason why the above example is an error is that T1 is not deduced. In addition, the requirement of performing the deduction for a function parameter pack is that the pack should occur at the end of the parameter-declaration-list. Does the deduction really need that requirement?

Consider an example in the GCC bug file list

template<int N> struct UniqueType{};

template<class ...T, class U, class... Y>
void fun(T..., U, Y...){}

fun(UniqueType<0>{},UniqueType<1>{},UniqueType<2>{});

U is deduced with UniqueType<0>. T is deduced with an empty sequence. The behavior is more and less related to the above rule: T is not deduced and otherwise deduced to an empty, U and Y participate in the deduction. If this result is the intent of the standard, the comment in the above should also be changed to

// error: Types is deduced to empty, wrong number of arguments

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