求不定参数的长度

#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

posted @ 2017-10-23 15:37  于光远  阅读(198)  评论(0编辑  收藏  举报