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