// copy.cpp -- copy() and iterators
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;
// the following is needed for the CodeWarrior version current 
// at the time this CD was put together
using namespace rel_ops;

int main()
{
	int casts[10] = {6, 7, 2, 9 ,4 , 11, 8, 7, 10, 5};
	vector<int> dice(10);
    // copy from array to vector
	copy(casts, casts + 10, dice.begin());
    cout << "Let the dice be cast!\n";
    // create an ostream iterator
    ostream_iterator<int, char> out_iter(cout, " ");
    // copy from vector to output
	copy(dice.begin(), dice.end(), out_iter);
	cout << endl;
    cout <<"Implicit use of reverse iterator.\n";
// the following is commented out for the CodeWarrior version
// at the time this CD was put together.  You may want to download a newer version.    
//    copy(dice.rbegin(), dice.rend(), out_iter);
	cout << endl;
    cout <<"Explicit use of reverse iterator.\n";
    vector<int>::reverse_iterator ri;
    for (ri = dice.rbegin(); ri != dice.rend(); ++ri)
        cout << *ri << ' ';
    cout << endl;

	return 0;
}