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

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4.  
  5. #include <iostream>
  6. #include <set>
  7. // #include <algorithm>
  8. #include <functional>
  9.  
  10.  
  11. #ifdef MAIN 
  12. #define mset5_test main
  13. #endif
  14.  
  15. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  16. using namespace std;
  17. #endif
  18.  
  19. static bool less_than(int a_, int b_)
  20. {
  21.   return a_ < b_;
  22. }
  23.  
  24. static bool greater_than(int a_, int b_)
  25. {
  26.   return a_ > b_;
  27. }
  28.  
  29. int mset5_test(int, char**)
  30. {
  31.   cout<<"Results of mset5_test:"<<endl;
  32.   int array [] = { 3, 6, 1, 9 };
  33.   
  34.   typedef pointer_to_binary_function<int, int, bool> fn_type;
  35.   typedef __multiset__<int, fn_type, allocator<int> > mset;
  36.   fn_type f(less_than);
  37.  
  38.   mset s1(array+0, array + 4 , f );
  39.   mset::const_iterator i = s1.begin();
  40.  
  41.   cout << "Using less_than: " << endl;
  42.   while(i != s1.end())
  43.     cout << *i++ << endl;
  44.   fn_type g(greater_than);
  45.   mset s2(array, array + 4, g);
  46.   i = s2.begin();
  47.   cout << "Using greater_than: " << endl;
  48.   while(i != s2.end())
  49.     cout << *i++ << endl;
  50.  
  51.   return 0;
  52. }
  53.  
  54.