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

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <algorithm>
  5. #include <iostream>
  6.  
  7. #ifdef MAIN 
  8. #define findif0_test main
  9. #endif
  10. static bool odd(int a_)
  11. {
  12.   return a_ % 2;
  13. }
  14.  
  15. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  16. using namespace std;
  17. #endif
  18. int findif0_test(int, char**)
  19. {
  20.   cout<<"Results of findif0_test:"<<endl;
  21.  
  22. int numbers[6] = { 2, 4, 8, 15, 32, 64 };
  23.  
  24.   int* location = find_if((int*)numbers, (int*)numbers + 6, odd);
  25.   if(location != numbers + 6)
  26.     cout
  27.       << "Value "
  28.       << *location
  29.       << " at offset "
  30.       <<(location - numbers)
  31.       << " is odd"
  32.       << endl;
  33.   return 0;
  34. }
  35.