在使用 C++11 模板参数包时,我想出了以下代码:
#include <cstdio>
static void testFunc(int i1, int i2) {
printf("testFunc(%d, %d)\n", i1, i2);
}
template <size_t... Indices> void wrapper() {
testFunc(Indices...);
}
int main(int argc, char *argv[]) {
wrapper<1, 2>();
return 0;
}
尝试使用 g++4.8.2 编译它导致
"too few arguments to function ‘void testFunc(int, int)’"
错误。
这不是有效的 C++ 还是 g++ 还没有实现这种非类型模板参数包的使用?