#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;
int main()
{
vector<char> vectorObject(10);
deque<char> deq(10);
int i;
for(i = 0; i < 10; i++)
vectorObject[ i ] = 'A' + i;
for(i = 0; i < 10; i++)
deq[ i ] = '0' + i;
cout << "Original contents of vectorObject:";
for(i = 0; i < 10; i++)
cout << vectorObject[ i ] << " ";
cout << endl;
cout << "Original contents of deq:";
for(i = 0; i < 10; i++)
cout << deq[ i ] << " ";
cout << endl;
// swap ranges in vectorObject and deq
swap_ranges(vectorObject.begin() + 2, vectorObject.end() - 3, deq.begin() + 4);
cout << "Contents of vectorObject after swap:";
for(i = 0; i < 10; i++)
cout << vectorObject[ i ] << " ";
cout << endl;
cout << "Contents of deq after swap:";
for(i = 0; i < 10; i++)
cout << deq[ i ] << " ";
cout << endl;
return 0;
}
|