#include <iostream>
#include <string>
using namespace std;
template<typename... Args>
void f(Args... args)
{
cout<<sizeof...(Args)<<endl;
cout<<sizeof...(args)<<endl;
}
int main()
{
f(8, 9, 10);
return 0;
}
运行程序输出:
3
3
C++(11):sizeof求值变长模板参数数量
于 2023-05-17 12:24:40 首次发布
本文探讨了在C++11中如何使用`sizeof`运算符和模板元编程技巧来求解变长模板参数的数量,这对于理解和实现泛型编程中的类型信息探测至关重要。
摘要由CSDN通过智能技术生成