ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

_function_base.h
Go to the documentation of this file.
00001 /*
00002  *
00003  * Copyright (c) 1994
00004  * Hewlett-Packard Company
00005  *
00006  * Copyright (c) 1996-1998
00007  * Silicon Graphics Computer Systems, Inc.
00008  *
00009  * Copyright (c) 1997
00010  * Moscow Center for SPARC Technology
00011  *
00012  * Copyright (c) 1999
00013  * Boris Fomitchev
00014  *
00015  * This material is provided "as is", with absolutely no warranty expressed
00016  * or implied. Any use is at your own risk.
00017  *
00018  * Permission to use or copy this software for any purpose is hereby granted
00019  * without fee, provided the above notices are retained on all copies.
00020  * Permission to modify the code and to distribute modified code is granted,
00021  * provided the above notices are retained, and a notice that the code was
00022  * modified is included with the above copyright notice.
00023  *
00024  */
00025 
00026 /* NOTE: This is an internal header file, included by other STL headers.
00027  *   You should not attempt to use it directly.
00028  */
00029 
00030 #ifndef _STLP_INTERNAL_FUNCTION_BASE_H
00031 #define _STLP_INTERNAL_FUNCTION_BASE_H
00032 
00033 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_TYPE_TRAITS_H)
00034 #  include <stl/type_traits.h>
00035 #endif
00036 
00037 _STLP_BEGIN_NAMESPACE
00038 
00039 template <class _Arg, class _Result>
00040 struct unary_function {
00041   typedef _Arg argument_type;
00042   typedef _Result result_type;
00043 #if !defined (__BORLANDC__) || (__BORLANDC__ < 0x580)
00044 protected:
00045   /* This class purpose is to be derived but it is not polymorphic so users should never try
00046    * to destroy an instance of it directly. The protected non-virtual destructor make this
00047    * fact obvious at compilation time. */
00048   ~unary_function() {}
00049 #endif
00050 };
00051 
00052 template <class _Arg1, class _Arg2, class _Result>
00053 struct binary_function {
00054   typedef _Arg1 first_argument_type;
00055   typedef _Arg2 second_argument_type;
00056   typedef _Result result_type;
00057 #if !defined (__BORLANDC__) || (__BORLANDC__ < 0x580)
00058 protected:
00059   /* See unary_function comment. */
00060   ~binary_function() {}
00061 #endif
00062 };
00063 
00064 template <class _Tp>
00065 struct equal_to : public binary_function<_Tp, _Tp, bool> {
00066   bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; }
00067 };
00068 
00069 template <class _Tp>
00070 struct less : public binary_function<_Tp,_Tp,bool>
00071 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
00072 /* less is the default template parameter for many STL containers, to fully use
00073  * the move constructor feature we need to know that the default less is just a
00074  * functor.
00075  */
00076               , public __stlport_class<less<_Tp> >
00077 #endif
00078 {
00079   bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; }
00080 
00081 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
00082   void _M_swap_workaround(less<_Tp>& __x) {}
00083 #endif
00084 };
00085 
00086 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
00087 template <class _Tp>
00088 struct __type_traits<less<_Tp> > {
00089 #if !defined (__BORLANDC__)
00090   typedef typename _IsSTLportClass<less<_Tp> >::_Ret _STLportLess;
00091 #else
00092   enum { _Is = _IsSTLportClass<less<_Tp> >::_Is };
00093   typedef typename __bool2type<_Is>::_Ret _STLportLess;
00094 #endif
00095   typedef _STLportLess has_trivial_default_constructor;
00096   typedef _STLportLess has_trivial_copy_constructor;
00097   typedef _STLportLess has_trivial_assignment_operator;
00098   typedef _STLportLess has_trivial_destructor;
00099   typedef _STLportLess is_POD_type;
00100 };
00101 #endif
00102 
00103 _STLP_MOVE_TO_PRIV_NAMESPACE
00104 
00105 template <class _Tp>
00106 less<_Tp> __less(_Tp* ) { return less<_Tp>(); }
00107 
00108 template <class _Tp>
00109 equal_to<_Tp> __equal_to(_Tp* ) { return equal_to<_Tp>(); }
00110 
00111 _STLP_MOVE_TO_STD_NAMESPACE
00112 
00113 template <class _Tp>
00114 struct plus : public binary_function<_Tp, _Tp, _Tp> {
00115   _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; }
00116 };
00117 
00118 template <class _Tp>
00119 struct minus : public binary_function<_Tp, _Tp, _Tp> {
00120   _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; }
00121 };
00122 
00123 _STLP_MOVE_TO_PRIV_NAMESPACE
00124 
00125 template <class _Tp>
00126 plus<_Tp> __plus(_Tp* ) { return plus<_Tp>(); }
00127 
00128 template <class _Tp>
00129 minus<_Tp> __minus(_Tp* ) { return minus<_Tp>(); }
00130 
00131 _STLP_MOVE_TO_STD_NAMESPACE
00132 
00133 template <class _Tp>
00134 struct multiplies : public binary_function<_Tp, _Tp, _Tp> {
00135   _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; }
00136 };
00137 
00138 _STLP_MOVE_TO_PRIV_NAMESPACE
00139 
00140 template <class _Pair>
00141 struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> {
00142   const typename _Pair::first_type& operator()(const _Pair& __x) const {
00143     return __x.first;
00144   }
00145 };
00146 
00147 template <class _Pair>
00148 struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type> {
00149   const typename _Pair::second_type& operator()(const _Pair& __x) const {
00150     return __x.second;
00151   }
00152 };
00153 
00154 // project1st and project2nd are extensions: they are not part of the standard
00155 template <class _Arg1, class _Arg2>
00156 struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1> {
00157   _Arg1 operator()(const _Arg1& __x, const _Arg2&) const { return __x; }
00158 };
00159 
00160 template <class _Arg1, class _Arg2>
00161 struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2> {
00162   _Arg2 operator()(const _Arg1&, const _Arg2& __y) const { return __y; }
00163 };
00164 
00165 #if defined (_STLP_MULTI_CONST_TEMPLATE_ARG_BUG)
00166 // fbp : sort of select1st just for maps
00167 template <class _Pair, class _Whatever>
00168 // JDJ (CW Pro1 doesn't like const when first_type is also const)
00169 struct __Select1st_hint : public unary_function<_Pair, _Whatever> {
00170     const _Whatever& operator () (const _Pair& __x) const { return __x.first; }
00171 };
00172 #  define  _STLP_SELECT1ST(__x,__y) _STLP_PRIV __Select1st_hint< __x, __y >
00173 #else
00174 #  define  _STLP_SELECT1ST(__x, __y) _STLP_PRIV _Select1st< __x >
00175 #endif
00176 
00177 template <class _Tp>
00178 struct _Identity : public unary_function<_Tp,_Tp> {
00179   const _Tp& operator()(const _Tp& __x) const { return __x; }
00180 };
00181 
00182 template <class _Result, class _Argument>
00183 struct _Constant_unary_fun {
00184   typedef _Argument argument_type;
00185   typedef  _Result  result_type;
00186   result_type _M_val;
00187 
00188   _Constant_unary_fun(const result_type& __v) : _M_val(__v) {}
00189   const result_type& operator()(const _Argument&) const { return _M_val; }
00190 };
00191 
00192 template <class _Result, class _Arg1, class _Arg2>
00193 struct _Constant_binary_fun {
00194   typedef  _Arg1   first_argument_type;
00195   typedef  _Arg2   second_argument_type;
00196   typedef  _Result result_type;
00197   _Result _M_val;
00198 
00199   _Constant_binary_fun(const _Result& __v) : _M_val(__v) {}
00200   const result_type& operator()(const _Arg1&, const _Arg2&) const {
00201     return _M_val;
00202   }
00203 };
00204 
00205 // identity_element (not part of the C++ standard).
00206 template <class _Tp> inline _Tp __identity_element(plus<_Tp>) {  return _Tp(0); }
00207 template <class _Tp> inline _Tp __identity_element(multiplies<_Tp>) { return _Tp(1); }
00208 
00209 _STLP_MOVE_TO_STD_NAMESPACE
00210 
00211 _STLP_END_NAMESPACE
00212 
00213 #endif /* _STLP_INTERNAL_FUNCTION_BASE_H */
00214 
00215 // Local Variables:
00216 // mode:C++
00217 // End:

Generated on Sat May 26 2012 04:27:37 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.