- iota(...) 填充序列
参考资料:C++ iota函数用法详解
语法:iota(start pos, end pos, start value)
其中的类型只要支持自增自减就可以。
#include#include "vector" #include "numeric" using namespace std; template void myPrint(T& data){ for(auto i:data) cout< v_nums(10); iota(v_nums.begin(), v_nums.end(), -3); myPrint(v_nums); vector v_char(22); iota(v_char.begin(), v_char.end(), 'd'); myPrint(v_char); cout< 输出结果:



