传入多个类型的模板,t1为T1类型的引用,Types&...为传入的多个类型的引用
templatevoid print(const T1& t1, const Types&... Tn) { cout << t1 << endl; print(Tn...); }
单一类型模板使用
templatevoid PrintElement(const T& coll) //coll是T类型的引用 { //遍历 for(auto& elem:coll) { cout << elem << endl; } }
模板别名使用
//模板别名使用 templateusing Vec = vector >;
测试模板别名
Vecvv{ list {"one","two","three"}}; for (auto v:vv) { for (auto item : v) { cout << item << endl; } }
测试模板函数print
print(7.5,"hello",bitset<16>(377),42);
测试模板函数PrintEl



