Use indexer to add elements to a deque
#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
#include <deque>
using namespace std;
int main()
{
deque<int> deque1(5);
for (int i = 0; i < 5; ++i)
deque1[i] = i + 5;
deque<int>::iterator pos;
for (pos=deque1.begin(); pos!=deque1.end(); ++pos) {
cout << *pos << ' ';
}
return 0;
}
/*
5 6 7 8 9
*/
Related examples in the same category