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

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