読者です 読者をやめる 読者になる 読者になる

入れ子にすればN^2個に展開

#include <iostream>

template <typename... Ts>
int f(Ts... i) {
    int k = 0;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-value"
    (... , (i, (... , (++k, i))));
#pragma GCC diagnostic pop
    return k;
}

int main() {
    std::cout << f(0) << std::endl;
    std::cout << f(0, 0) << std::endl;
    std::cout << f(0, 0, 0) << std::endl;
    std::cout << f(0, 0, 0, 0) << std::endl;
    std::cout << f(0, 0, 0, 0, 0) << std::endl;
}

1
4
9
16
25