Parameter pack in non-last position in function formal parameter list?
Avi Kivity
avi@cloudius-systems.com
Fri Jun 19 16:37:00 GMT 2015
On 06/19/2015 07:31 PM, Marc Glisse wrote:
> On Fri, 19 Jun 2015, Avi Kivity wrote:
>
>> Consider
>>
>> template <typename... X, typename Y>
>> void f(X... x, Y y) {
>> }
>>
>>
>> int main(int ac, char** av) {
>> f(1, 2, 3, 4);
>> return 0;
>> }
>>
>> is this legal?
>
> No.
>
>> So it's not complaining that f() is illegal, yet it id not deducing
>> X... as int, int, int.
>
> That's what the standard says. You can still call it as:
> f<int,int,int>(1, 2, 3, 4);
>
> (the question is not specific to gcc, so it would be more appropriate
> on a general C++ forum like stackoverflow.com)
>
Thanks.
I wonder if gcc can give a better diagnostic here. Instead of
./variadic-function-nonlast.cc:9:15: note: candidate expects 1
argument, 4 provided
it might say,
./variadic-function-nonlast.cc:9:15: note: candidate expects 1
argument, 4 provided
./variadic-function-nonlast.cc:9:15: note: parameter pack `X' in
non-last position deduced as empty parameter pack
More information about the Gcc-help
mailing list