home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / test / regression / repcpif1.cpp < prev    next >
C/C++ Source or Header  |  2000-12-07  |  841b  |  39 lines

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <algorithm>
  5. #include <vector>
  6. #include <iostream>
  7. #include <iterator>
  8. #include <functional>
  9.  
  10. #ifdef MAIN 
  11. #define repcpif1_test main
  12. #endif
  13. static bool odd(int a_)
  14. {
  15.   return a_ % 2;
  16. }
  17.  
  18. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  19. using namespace std;
  20. #endif
  21. int repcpif1_test(int, char**)
  22. {
  23.   cout<<"Results of repcpif1_test:"<<endl;
  24.  
  25.   vector <int> v1(10);
  26.   for(int i = 0; i < v1.size(); i++)
  27.     v1[i] = i % 5;
  28.   ostream_iterator <int> iter(cout, " ");
  29.   copy(v1.begin(), v1.end(), iter);
  30.   cout << endl;
  31.   vector <int> v2(v1.size());
  32.   replace_copy_if(v1.begin(), v1.end(), v2.begin(), odd, 42);
  33.   copy(v1.begin(), v1.end(), iter);
  34.   cout << endl;
  35.   copy(v2.begin(), v2.end(), iter);
  36.   cout << endl;
  37.   return 0;
  38. }
  39.