可变参数模板展开
//#include
//#include
//#include
//#include
//#include <type_traits>
//#include
void printer()
{
}
template
void printer(T a) {
std::cout << a << std::endl;
}
//c++11
template<class …Args>
void printer(Args&&… args) {
using expander = int[];
expander{ (printer(args),0)… };//逗號表達式
}
template
void printer(T a) {
std::cout << a << std::endl;
}
template<class …Args>
void printer(Args&&… args) {
(printer(args), …);//折疊表達式
}
int main()
{
printer(1, 2, 3, “abc”);
}
總結
- 上一篇: Babel入门
- 下一篇: 计算机辅助设计教案板书,计算机辅助设计教