home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stl453up.zip / stl453fx / test / regression / vec2.cpp < prev    next >
C/C++ Source or Header  |  2002-04-29  |  933b  |  46 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 vec2_test main
  10. #endif
  11.  
  12. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  13. using namespace std;
  14. #endif
  15.  
  16. static void print(vector<double>& vector_)
  17. {
  18.   for(int i = 0; i < vector_.size(); i++)
  19.     cout << vector_[i] << " ";
  20.   cout << endl;
  21. }
  22.  
  23. int vec2_test(int, char**)
  24. {
  25.   cout<<"Results of vec2_test:"<<endl;
  26.  
  27.   vector<double> v1; // Empty vector of doubles.
  28.   v1.push_back(32.1);
  29.   v1.push_back(40.5);
  30.   vector<double> v2; // Another empty vector of doubles.
  31.   v2.push_back(3.56);
  32.   cout << "v1 = ";
  33.   print(v1);
  34.   cout << "v2 = ";
  35.   print(v2);
  36.   v1.swap(v2); // Swap the vector's contents.
  37.   cout << "v1 = ";
  38.   print(v1);
  39.   cout << "v2 = ";
  40.   print(v2);
  41.   v2 = v1; // Assign one vector to another.
  42.   cout << "v2 = ";
  43.   print(v2);
  44.   return 0;
  45. }
  46.