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

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