epoc32/include/stdapis/stlport/stl/_function_base.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/stlport/stl/_function_base.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,226 @@
     1.4 +/*
     1.5 + *
     1.6 + * Copyright (c) 1994
     1.7 + * Hewlett-Packard Company
     1.8 + *
     1.9 + * Copyright (c) 1996-1998
    1.10 + * Silicon Graphics Computer Systems, Inc.
    1.11 + *
    1.12 + * Copyright (c) 1997
    1.13 + * Moscow Center for SPARC Technology
    1.14 + *
    1.15 + * Copyright (c) 1999 
    1.16 + * Boris Fomitchev
    1.17 + *
    1.18 + * This material is provided "as is", with absolutely no warranty expressed
    1.19 + * or implied. Any use is at your own risk.
    1.20 + *
    1.21 + * Permission to use or copy this software for any purpose is hereby granted 
    1.22 + * without fee, provided the above notices are retained on all copies.
    1.23 + * Permission to modify the code and to distribute modified code is granted,
    1.24 + * provided the above notices are retained, and a notice that the code was
    1.25 + * modified is included with the above copyright notice.
    1.26 + *
    1.27 + */
    1.28 +
    1.29 +/* NOTE: This is an internal header file, included by other STL headers.
    1.30 + *   You should not attempt to use it directly.
    1.31 + */
    1.32 +
    1.33 +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
    1.34 +#define _STLP_INTERNAL_FUNCTION_BASE_H
    1.35 +
    1.36 +#ifndef _STLP_CONFIG_H
    1.37 +#include <stl/_config.h>
    1.38 +#endif
    1.39 +
    1.40 +_STLP_BEGIN_NAMESPACE
    1.41 +
    1.42 +template <class _Arg, class _Result>
    1.43 +struct unary_function {
    1.44 +  typedef _Arg argument_type;
    1.45 +  typedef _Result result_type;
    1.46 +};
    1.47 +
    1.48 +template <class _Arg1, class _Arg2, class _Result>
    1.49 +struct binary_function {
    1.50 +  typedef _Arg1 first_argument_type;
    1.51 +  typedef _Arg2 second_argument_type;
    1.52 +  typedef _Result result_type;
    1.53 +};      
    1.54 +
    1.55 +template <class _Tp>
    1.56 +struct equal_to : public binary_function<_Tp,_Tp,bool> 
    1.57 +{
    1.58 +  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; }
    1.59 +};
    1.60 +
    1.61 +template <class _Tp>
    1.62 +struct not_equal_to : public binary_function<_Tp,_Tp,bool> 
    1.63 +{
    1.64 +  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x != __y; }
    1.65 +};
    1.66 +
    1.67 +template <class _Tp>
    1.68 +struct greater : public binary_function<_Tp,_Tp,bool> 
    1.69 +{
    1.70 +  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x > __y; }
    1.71 +};
    1.72 +
    1.73 +template <class _Tp>
    1.74 +struct less : public binary_function<_Tp,_Tp,bool> 
    1.75 +{
    1.76 +  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; }
    1.77 +};
    1.78 +
    1.79 +template <class _Tp>
    1.80 +struct greater_equal : public binary_function<_Tp,_Tp,bool>
    1.81 +{
    1.82 +  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x >= __y; }
    1.83 +};
    1.84 +
    1.85 +template <class _Tp>
    1.86 +struct less_equal : public binary_function<_Tp,_Tp,bool> 
    1.87 +{
    1.88 +  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x <= __y; }
    1.89 +};
    1.90 +
    1.91 +template <class _Tp>
    1.92 +less<_Tp> __less(_Tp* ) { return less<_Tp>(); }
    1.93 +
    1.94 +template <class _Tp>
    1.95 +equal_to<_Tp> __equal_to(_Tp* ) { return equal_to<_Tp>(); }
    1.96 +
    1.97 +template <class _Tp>
    1.98 +struct plus : public binary_function<_Tp,_Tp,_Tp> {
    1.99 +  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; }
   1.100 +};
   1.101 +
   1.102 +template <class _Tp>
   1.103 +struct minus : public binary_function<_Tp,_Tp,_Tp> {
   1.104 +  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; }
   1.105 +};
   1.106 +
   1.107 +template <class _Tp>
   1.108 +plus<_Tp> __plus(_Tp* ) { return plus<_Tp>(); }
   1.109 +
   1.110 +template <class _Tp>
   1.111 +minus<_Tp> __minus(_Tp* ) { return minus<_Tp>(); }
   1.112 +
   1.113 +template <class _Tp>
   1.114 +struct multiplies : public binary_function<_Tp,_Tp,_Tp> {
   1.115 +  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; }
   1.116 +};
   1.117 +
   1.118 +template <class _Tp>
   1.119 +struct divides : public binary_function<_Tp,_Tp,_Tp> {
   1.120 +  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x / __y; }
   1.121 +};
   1.122 +
   1.123 +template <class _Tp>
   1.124 +struct modulus : public binary_function<_Tp,_Tp,_Tp> 
   1.125 +{
   1.126 +  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x % __y; }
   1.127 +};
   1.128 +
   1.129 +template <class _Tp>
   1.130 +struct negate : public unary_function<_Tp,_Tp> 
   1.131 +{
   1.132 +  _Tp operator()(const _Tp& __x) const { return -__x; }
   1.133 +};
   1.134 +
   1.135 +template <class _Tp>
   1.136 +struct logical_and : public binary_function<_Tp,_Tp,bool>
   1.137 +{
   1.138 +  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x && __y; }
   1.139 +};
   1.140 +
   1.141 +template <class _Tp>
   1.142 +struct logical_or : public binary_function<_Tp,_Tp,bool>
   1.143 +{
   1.144 +  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x || __y; }
   1.145 +};
   1.146 +
   1.147 +template <class _Tp>
   1.148 +struct logical_not : public unary_function<_Tp,bool>
   1.149 +{
   1.150 +  bool operator()(const _Tp& __x) const { return !__x; }
   1.151 +};
   1.152 +
   1.153 +template <class _Pair>
   1.154 +struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> {
   1.155 +  const typename _Pair::first_type& operator()(const _Pair& __x) const {
   1.156 +    return __x.first;
   1.157 +  }
   1.158 +};
   1.159 +
   1.160 +template <class _Pair>
   1.161 +struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type>
   1.162 +{
   1.163 +  const typename _Pair::second_type& operator()(const _Pair& __x) const {
   1.164 +    return __x.second;
   1.165 +  }
   1.166 +};
   1.167 +
   1.168 +// project1st and project2nd are extensions: they are not part of the standard
   1.169 +template <class _Arg1, class _Arg2>
   1.170 +struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1> {
   1.171 +  _Arg1 operator()(const _Arg1& __x, const _Arg2&) const { return __x; }
   1.172 +};
   1.173 +
   1.174 +template <class _Arg1, class _Arg2>
   1.175 +struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2> {
   1.176 +  _Arg2 operator()(const _Arg1&, const _Arg2& __y) const { return __y; }
   1.177 +};
   1.178 +
   1.179 +#ifdef _STLP_MULTI_CONST_TEMPLATE_ARG_BUG
   1.180 +// fbp : sort of select1st just for maps
   1.181 +template <class _Pair, class _Whatever>		
   1.182 +// JDJ (CW Pro1 doesn't like const when first_type is also const)
   1.183 +struct __Select1st_hint : public unary_function<_Pair, _Whatever> {
   1.184 +    const _Whatever& operator () (const _Pair& __x) const { return __x.first; }
   1.185 +};
   1.186 +# define  _STLP_SELECT1ST(__x,__y) __Select1st_hint< __x, __y >
   1.187 +# else
   1.188 +# define  _STLP_SELECT1ST(__x, __y) _Select1st< __x >
   1.189 +# endif
   1.190 +
   1.191 +template <class _Tp>
   1.192 +struct _Identity : public unary_function<_Tp,_Tp> {
   1.193 +  const _Tp& operator()(const _Tp& __x) const { return __x; }
   1.194 +};
   1.195 +
   1.196 +template <class _Result, class _Argument>
   1.197 +struct _Constant_unary_fun {
   1.198 +  typedef _Argument argument_type;
   1.199 +  typedef  _Result  result_type;
   1.200 +  result_type _M_val;
   1.201 +
   1.202 +  _Constant_unary_fun(const result_type& __v) : _M_val(__v) {}
   1.203 +  const result_type& operator()(const _Argument&) const { return _M_val; }
   1.204 +};
   1.205 +
   1.206 +template <class _Result, class _Arg1, class _Arg2>
   1.207 +struct _Constant_binary_fun {
   1.208 +  typedef  _Arg1   first_argument_type;
   1.209 +  typedef  _Arg2   second_argument_type;
   1.210 +  typedef  _Result result_type;
   1.211 +  _Result _M_val;
   1.212 +
   1.213 +  _Constant_binary_fun(const _Result& __v) : _M_val(__v) {}
   1.214 +  const result_type& operator()(const _Arg1&, const _Arg2&) const {
   1.215 +    return _M_val;
   1.216 +  }
   1.217 +};
   1.218 +
   1.219 +// identity_element (not part of the C++ standard).
   1.220 +template <class _Tp> inline _Tp __identity_element(plus<_Tp>) {  return _Tp(0); }
   1.221 +template <class _Tp> inline _Tp __identity_element(multiplies<_Tp>) { return _Tp(1); }
   1.222 +
   1.223 +_STLP_END_NAMESPACE
   1.224 +
   1.225 +#endif /* _STLP_INTERNAL_FUNCTION_BASE_H */
   1.226 +
   1.227 +// Local Variables:
   1.228 +// mode:C++
   1.229 +// End: