stl中的variadic template可变参数模板使用

#include<iostream>
#include <algorithm>

/* 终止循环操作 */
void printv()
{
   std::cout << std::endl;
}

template<typename A, typename... B>
void printv(A a, B...b)
{
   std::cout <<  a << ",";
   printv(b...);
}
int main()
{
    printv(7.5, "hello world", 9, 'c', 7.2);
    return 0;
}

输出:

7.5,hello world,9,c,7.2,

猜你喜欢

转载自blog.csdn.net/guoguangwu/article/details/89375636