home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / test / regression / vec7.cpp < prev    next >
C/C++ Source or Header  |  2000-12-07  |  884b  |  35 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 vec7_test main
  10. #endif
  11.  
  12. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  13. using namespace std;
  14. #endif
  15. int vec7_test(int, char**)
  16. {
  17.   cout<<"Results of vec7_test:"<<endl;
  18. int array1 [] = { 1, 4, 25 };
  19. int array2 [] = { 9, 16 };
  20.  
  21.   vector<int> v(array1, array1 + 3);
  22.   v.insert(v.begin(), 0); // Insert before first element.
  23.   v.insert(v.end(), 36); // Insert after last element.
  24.   int i;
  25.   for(i = 0; i < v.size(); i++)
  26.     cout << "v[" << i << "] = " << v[i] << endl;
  27.   cout << endl;
  28.   // Insert contents of array2 before fourth element.
  29.   v.insert(v.begin() + 3, array2, array2 + 2);
  30.   for(i = 0; i < v.size(); i++)
  31.     cout << "v[" << i << "] = " << v[i] << endl;
  32.   cout << endl;
  33.   return 0;
  34. }
  35.