variadic template(一)
使用可变参数模板重写print
#include<iostream> #include<bitset> using namespace std; void printX() { } template<typename T, typename... Types> void printX(const T& firstArg, const Types&... args) {
sizeof...(args); // get number of args cout << firstArg << endl; printX(args...); } int main() { printX(7.5, "hello", bitset<16>(377), 42); return 0; }