标签:style blog http color io os ar for strong
Fills the range [first, last)
with sequentially(循环的) increasing values, starting with value
and repetitively(重复地) evaluating ++value.
(none)
template<class ForwardIterator, class T> void iota(ForwardIterator first, ForwardIterator last, T value) { while(first != last) { *first++ = value; ++value; } }
我的例子:
1 #include <numeric> 2 #include <vector> 3 #include <iostream> 4 using namespace std; 5 6 int main() 7 { 8 int a[5]; 9 iota(a, a+5, 10); 10 for (auto &r: a) 11 cout << r ; 12 cout << endl; 13 14 vector<int> va(5); 15 iota(va.begin(), va.end(), 4); 16 for (auto &v : va) 17 cout << v << " "; 18 cout << endl; 19 20 vector<vector<int>::iterator> vb(va.size()); 21 itoa(vb.begin(), vb.end(), va.begin()); 22 for (auto &v : vb) 23 cout << *v << " "; 24 cout << endl; 25 }
输出结果:
10,11, 12, 13, 14
10,11, 12, 13, 14
10,11, 12, 13, 14
标签:style blog http color io os ar for strong
原文地址:http://www.cnblogs.com/457220157-FTD/p/4021902.html