home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stl2vac.zip / STLport-4_5_3.zip / STLport-4.5.3 / test / regression / uprbnd2.cpp < prev    next >
C/C++ Source or Header  |  2001-05-18  |  834b  |  36 lines

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <algorithm>
  5. #include <iostream>
  6. #include <cstring>
  7.  
  8. #ifdef MAIN 
  9. #define uprbnd2_test main
  10. #endif
  11.  
  12. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  13. using namespace std;
  14. #endif
  15.  
  16. static bool char_str_less(const char* a_, const char* b_)
  17. {
  18.   return strcmp(a_, b_) < 0 ? 1 : 0;
  19. }
  20.  
  21. int uprbnd2_test(int, char**)
  22. {
  23.   cout<<"Results of uprbnd2_test:"<<endl;
  24.  
  25. char* str [] = { "a", "a", "b", "b", "q", "w", "z" };
  26.  
  27.   const unsigned strCt = sizeof(str)/sizeof(str[0]);
  28.   // DEC C++ generates incorrect template instatiation code 
  29.   // for "d" so must cast 
  30.   cout
  31.     << "d can be inserted at index: "
  32.     << (upper_bound((char**)str,  (char**)str + strCt, (const char *)"d", char_str_less) - str)
  33.     << endl;
  34.   return 0;
  35. }
  36.