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

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <iterator>
  7. #include <functional>
  8.  
  9. #ifdef MAIN 
  10. #define ptrbinf1_test main
  11. #endif
  12. static int sum(int x_, int y_)
  13. {
  14.   return x_ + y_;
  15. }
  16.  
  17. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  18. using namespace std;
  19. #endif
  20. int ptrbinf1_test(int, char**)
  21. {
  22.   cout<<"Results of ptrbinf1_test:"<<endl;
  23.  
  24. int input1 [4] = { 7, 2, 3, 5 };
  25. int input2 [4] = { 1, 5, 5, 8 };
  26.  
  27.   int output [4];
  28.   transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, 
  29.     pointer_to_binary_function<int, int, int>(sum));
  30.   for(int i = 0; i < 4; i++)
  31.     cout << output[i] << endl;
  32.   return 0;
  33. }
  34.