////////////////////////////////////////
// 2018/04/15 19:00:54
// vector-begin
#include <iostream>
#include <vector>
#include <iterator>
#include <numeric>
using namespace std;
int main(){
vector<int> v(5);
// iota函数:STL序列依次递增函数
iota(v.begin(), v.end(), 1);
/*
iota 源码
void iota(_FwdIt _First, _FwdIt _Last, _Ty _Val)
{ // compute increasing sequence into [_First, _Last)
_DEBUG_RANGE(_First, _Last);
_Iota(_Unchecked(_First), _Unchecked(_Last), _Val);
}
void _Iota(_FwdIt _First, _FwdIt _Last, _Ty _Val)
{
// compute increasing sequence into [_First, _Last)
for (; _First != _Last; ++_First, ++_Val)
*_First = _Val;
}
*/
vector<int>::iterator it = v.begin();
while (it != v.end()){
cout << *(it++) << " ";
}
cout << endl;
// third element of the vector
it = v.begin() + 2;
cout << *it << endl;
return 0;
}
/*
OUTPUT:
1 2 3 4 5
3
*/