重点:
1.通过编译期if 判断。减少参数包特例化的步骤。C++17支持编译期if
//编译期进行判断
template<typename T,typename... Types>
void prinT(T const& first, Types const&... args)
{
cout << first << endl;
if constexpr (sizeof...(args) > 0)
{
prinT(args...);
}
}
int main()
{
prinT(1, 2, 3, 4, 5, 6);
return 0;
}