dimanche 12 mars 2017

Parameter pack ignored by deduction

Why can't my gcc-5.4.0 not deduce parameter packs if they do not appear in the end of the argument list of a function? While the call to works is deduced in a correct way way to works<int,int,int>, the call to fails is not deduced but instead only an empty parameter pack is assumed. Leading to an error message about too many provided arguments for the function.

#include <iostream>

template <typename...args_t>
void works (int first, args_t...args) {
    std::cout << __PRETTY_FUNCTION__ << std::endl;
}

template <typename...args_t>
void fails (args_...args, int last) {
    std::cout << __PRETTY_FUNCTION__ << std::endl;
}

int main () {
    works (0, 1, 2, 3);
    fails (0, 1, 2, 3);
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire