Parameter pack in non-last position in function formal parameter list?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

gcc complains:

./variadic-function-nonlast.cc: In function ‘int main(int, char**)’:
./variadic-function-nonlast.cc:9:15: error: no matching function for call to ‘f(int, int, int, int)’
   f(1, 2, 3, 4);
               ^
./variadic-function-nonlast.cc:4:6: note: candidate: template<class ... X, class Y> void f(X ..., Y)
 void f(X... x, Y y) {
      ^
./variadic-function-nonlast.cc:4:6: note: template argument deduction/substitution failed: ./variadic-function-nonlast.cc:9:15: note: candidate expects 1 argument, 4 provided
   f(1, 2, 3, 4);
               ^

So it's not complaining that f() is illegal, yet it id not deducing X... as int, int, int.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux