home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stl453up.zip / stl453fx / test / regression / foreach1.cpp < prev    next >
C/C++ Source or Header  |  2002-04-29  |  615b  |  32 lines

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <vector>
  5. #include <algorithm>
  6. #include <iostream>
  7.  
  8. #include "fadapter.h"
  9.  
  10. #ifdef MAIN 
  11. #define foreach1_test main
  12. #endif
  13.  
  14. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  15. using namespace std;
  16. #endif
  17. static void print_sqr(int a_)
  18. {
  19.   cout << a_ * a_ << " ";
  20. }
  21. int foreach1_test(int, char**)
  22. {
  23.   cout<<"Results of foreach1_test:"<<endl;
  24.  
  25.   vector <int> v1(10);
  26.   for(int i = 0; i < v1.size(); i++)
  27.     v1[i] = i;
  28.   for_each(v1.begin(), v1.end(), ptr_proc(print_sqr) );
  29.   cout << endl;
  30.   return 0;
  31. }
  32.