genericopenlibs/cppstdlib/stl/test/unit/unary.h
changeset 31 ce057bb09d0b
child 34 5fae379060a7
equal deleted inserted replaced
30:e20de85af2ee 31:ce057bb09d0b
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 #ifndef _unary_h
       
    18 #define _unary_h
       
    19 #include <cmath>
       
    20 #include <cfloat>
       
    21 #include <functional>    //*TY 12/26/1998 - added to get unary_function
       
    22 
       
    23 #if !defined (STLPORT) || defined (_STLP_USE_NAMESPACES)
       
    24 using std::unary_function;
       
    25 #endif
       
    26 
       
    27 struct odd : public unary_function<int, bool>
       
    28 {
       
    29 //  odd() {}
       
    30   bool operator()(int n_) const { return(n_ % 2) == 1; }
       
    31 };
       
    32 
       
    33 struct positive : public unary_function<int, bool>
       
    34 {
       
    35   typedef int argument_type;
       
    36   typedef bool result_type;
       
    37 //  positive() {}
       
    38   bool operator()(int n_) const { return n_ >= 0; }
       
    39 };
       
    40 
       
    41 struct square_root : public unary_function<double, double>
       
    42 {
       
    43   typedef double argument_type;
       
    44   typedef double result_type;
       
    45   square_root() {}
       
    46   square_root(const square_root &) {}
       
    47   double operator()(double x_) const
       
    48   { return ::sqrt(x_); }
       
    49 };
       
    50 #endif // _unary_h