home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stl2vac.zip / STLport-4_5_3.zip / STLport-4.5.3 / test / regression / iter4.cpp < prev    next >
C/C++ Source or Header  |  2000-12-07  |  723b  |  30 lines

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <iostream>
  5. #include <vector>
  6. #include <algorithm>
  7.  
  8. #ifdef MAIN 
  9. #define iter4_test main
  10. #endif
  11.  
  12. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  13. using namespace std;
  14. #endif
  15. int iter4_test(int, char**)
  16. {
  17.   cout<<"Results of iter4_test:"<<endl;
  18.   vector<int> v; // Empty vector of integers.
  19.   v.push_back(1);
  20.   v.push_back(2);
  21.   v.push_back(3);
  22.   // Position immediately after last item.
  23.   std::vector<int>::iterator i = v.end(); 
  24.   // Move back one and then access.
  25.   cout << "last element is " << *--i << endl; 
  26.   i -= 2; // Jump back two items.
  27.   cout << "first element is " << *i << endl;
  28.   return 0;
  29. }
  30.