[PR] この広告は3ヶ月以上更新がないため表示されています。
ホームページを更新後24時間以内に表示されなくなります。
/home/ntakagi/work/STLport-5.1.5/stlport/stl/_function_base.hGo 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 }; 00044 00045 template <class _Arg1, class _Arg2, class _Result> 00046 struct binary_function { 00047 typedef _Arg1 first_argument_type; 00048 typedef _Arg2 second_argument_type; 00049 typedef _Result result_type; 00050 }; 00051 00052 template <class _Tp> 00053 struct equal_to : public binary_function<_Tp, _Tp, bool> { 00054 bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; } 00055 }; 00056 00057 template <class _Tp> 00058 struct less : public binary_function<_Tp,_Tp,bool> 00059 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) 00060 /* less is the default template parameter for many STL containers, to fully use 00061 * the move constructor feature we need to know that the default less is just a 00062 * functor. 00063 */ 00064 , public __stlport_class<less<_Tp> > 00065 #endif 00066 { 00067 bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; } 00068 00069 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) 00070 //This is for a very special compiler config: partial template specialization 00071 //but no template function partial ordering. 00072 void swap(less<_Tp>&) {} 00073 #endif 00074 }; 00075 00076 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) 00077 template <class _Tp> 00078 struct __type_traits<less<_Tp> > { 00079 #if !defined (__BORLANDC__) 00080 typedef typename _IsSTLportClass<less<_Tp> >::_Ret _STLportLess; 00081 #else 00082 enum { _Is = _IsSTLportClass<less<_Tp> >::_Is }; 00083 typedef typename __bool2type<_Is>::_Ret _STLportLess; 00084 #endif 00085 typedef _STLportLess has_trivial_default_constructor; 00086 typedef _STLportLess has_trivial_copy_constructor; 00087 typedef _STLportLess has_trivial_assignment_operator; 00088 typedef _STLportLess has_trivial_destructor; 00089 typedef _STLportLess is_POD_type; 00090 }; 00091 #endif 00092 00093 _STLP_MOVE_TO_PRIV_NAMESPACE 00094 00095 template <class _Tp> 00096 less<_Tp> __less(_Tp* ) { return less<_Tp>(); } 00097 00098 template <class _Tp> 00099 equal_to<_Tp> __equal_to(_Tp* ) { return equal_to<_Tp>(); } 00100 00101 _STLP_MOVE_TO_STD_NAMESPACE 00102 00103 template <class _Tp> 00104 struct plus : public binary_function<_Tp, _Tp, _Tp> { 00105 _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; } 00106 }; 00107 00108 template <class _Tp> 00109 struct minus : public binary_function<_Tp, _Tp, _Tp> { 00110 _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; } 00111 }; 00112 00113 _STLP_MOVE_TO_PRIV_NAMESPACE 00114 00115 template <class _Tp> 00116 plus<_Tp> __plus(_Tp* ) { return plus<_Tp>(); } 00117 00118 template <class _Tp> 00119 minus<_Tp> __minus(_Tp* ) { return minus<_Tp>(); } 00120 00121 _STLP_MOVE_TO_STD_NAMESPACE 00122 00123 template <class _Tp> 00124 struct multiplies : public binary_function<_Tp, _Tp, _Tp> { 00125 _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; } 00126 }; 00127 00128 _STLP_MOVE_TO_PRIV_NAMESPACE 00129 00130 template <class _Pair> 00131 struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> { 00132 const typename _Pair::first_type& operator()(const _Pair& __x) const { 00133 return __x.first; 00134 } 00135 }; 00136 00137 template <class _Pair> 00138 struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type> { 00139 const typename _Pair::second_type& operator()(const _Pair& __x) const { 00140 return __x.second; 00141 } 00142 }; 00143 00144 // project1st and project2nd are extensions: they are not part of the standard 00145 template <class _Arg1, class _Arg2> 00146 struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1> { 00147 _Arg1 operator()(const _Arg1& __x, const _Arg2&) const { return __x; } 00148 }; 00149 00150 template <class _Arg1, class _Arg2> 00151 struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2> { 00152 _Arg2 operator()(const _Arg1&, const _Arg2& __y) const { return __y; } 00153 }; 00154 00155 #if defined (_STLP_MULTI_CONST_TEMPLATE_ARG_BUG) 00156 // fbp : sort of select1st just for maps 00157 template <class _Pair, class _Whatever> 00158 // JDJ (CW Pro1 doesn't like const when first_type is also const) 00159 struct __Select1st_hint : public unary_function<_Pair, _Whatever> { 00160 const _Whatever& operator () (const _Pair& __x) const { return __x.first; } 00161 }; 00162 # define _STLP_SELECT1ST(__x,__y) _STLP_PRIV __Select1st_hint< __x, __y > 00163 #else 00164 # define _STLP_SELECT1ST(__x, __y) _STLP_PRIV _Select1st< __x > 00165 #endif 00166 00167 template <class _Tp> 00168 struct _Identity : public unary_function<_Tp,_Tp> { 00169 const _Tp& operator()(const _Tp& __x) const { return __x; } 00170 }; 00171 00172 template <class _Result, class _Argument> 00173 struct _Constant_unary_fun { 00174 typedef _Argument argument_type; 00175 typedef _Result result_type; 00176 result_type _M_val; 00177 00178 _Constant_unary_fun(const result_type& __v) : _M_val(__v) {} 00179 const result_type& operator()(const _Argument&) const { return _M_val; } 00180 }; 00181 00182 template <class _Result, class _Arg1, class _Arg2> 00183 struct _Constant_binary_fun { 00184 typedef _Arg1 first_argument_type; 00185 typedef _Arg2 second_argument_type; 00186 typedef _Result result_type; 00187 _Result _M_val; 00188 00189 _Constant_binary_fun(const _Result& __v) : _M_val(__v) {} 00190 const result_type& operator()(const _Arg1&, const _Arg2&) const { 00191 return _M_val; 00192 } 00193 }; 00194 00195 // identity_element (not part of the C++ standard). 00196 template <class _Tp> inline _Tp __identity_element(plus<_Tp>) { return _Tp(0); } 00197 template <class _Tp> inline _Tp __identity_element(multiplies<_Tp>) { return _Tp(1); } 00198 00199 _STLP_MOVE_TO_STD_NAMESPACE 00200 00201 _STLP_END_NAMESPACE 00202 00203 #endif /* _STLP_INTERNAL_FUNCTION_BASE_H */ 00204 00205 // Local Variables: 00206 // mode:C++ 00207 // End:
Generated on Mon Mar 10 15:32:23 2008 by ![]() |