求不定参数的长度

#include <iostream>
using namespace std;

template<typename... Arguments>
void func(const Arguments &... evt){
        cout<<sizeof...(evt)<<endl;
}


int main(){
        func(1,2,"hello",3);

}

ubuntu@ubuntu-vm:~/workspace/template$ g++ main.cpp --std=c++11
ubuntu@ubuntu-vm:~/workspace/template$ ./a.out
4

原文地址:https://www.cnblogs.com/yuguangyuan/p/7717018.html