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

  1. #ifndef _unary_h
  2. #define _unary_h
  3. #include <cmath>
  4. #include <cfloat>
  5. #include <functional>        //*TY 12/26/1998 - added to get unary_function
  6.  
  7. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  8. using std::unary_function;
  9. #endif
  10.  
  11. struct odd : public unary_function<int, bool>
  12. {
  13. //  odd() {}
  14.   bool operator()(int n_) const { return(n_ % 2) == 1; }
  15. };
  16.  
  17. struct positive : public unary_function<int, bool>
  18. {
  19.   typedef int argument_type;
  20.   typedef bool result_type;
  21. //  positive() {}
  22.   bool operator()(int n_) const { return n_ >= 0; }
  23. };
  24.  
  25. struct square_root : public unary_function<double, double>
  26. {
  27.   typedef double argument_type;
  28.   typedef double result_type;
  29.   square_root() {}
  30.   square_root(const square_root &) {}
  31.   double operator()(double x_) const { 
  32.   # if !defined(STLPORT) || defined (__STL_USE_NAMESPACES)
  33.     using namespace std;
  34.   # endif
  35.     return sqrt(x_); 
  36.   }
  37. };
  38. #endif // _unary_h
  39.