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