00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #ifndef COMSTL_INCL_H_COMSTL
00060 # include "comstl.h"
00061 #endif
00062 #ifndef COMSTL_INCL_H_COMSTL_REFCOUNT_FUNCTIONS
00063 # include "comstl_refcount_functions.h"
00064 #endif
00065 #include <functional>
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 #ifndef _COMSTL_NO_NAMESPACE
00085 # if defined(_STLSOFT_NO_NAMESPACE) || \
00086 defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00087
00088 namespace comstl
00089 {
00090 # else
00091
00092
00093 namespace stlsoft
00094 {
00095
00096 namespace comstl_project
00097 {
00098
00099 # endif
00100 #endif
00101
00102
00103
00104
00105
00113 template <ss_typename_param_k I>
00114 struct interface_release
00115 : public comstl_ns_qual_std(unary_function)<I*, void>
00116 {
00117 public:
00118 typedef I interface_type;
00119
00123 void operator ()(interface_type *pi)
00124 {
00125 safe_release(pi);
00126 }
00127 };
00128
00136 template <ss_typename_param_k I>
00137 struct interface_addref
00138 : public comstl_ns_qual_std(unary_function)<I*, void>
00139 {
00140 public:
00141 typedef I interface_type;
00142
00146 void operator ()(interface_type *pi)
00147 {
00148 safe_addref(pi);
00149 }
00150 };
00151
00158 template< ss_typename_param_k R
00159 , ss_typename_param_k T
00160 >
00161 class std_mem_fun_t
00162 : public comstl_ns_qual_std(unary_function)<T*, R>
00163 {
00164 public:
00165 typedef R return_type;
00166 typedef T operand_class_type;
00167 typedef return_type (STDAPICALLTYPE T::*method_type)();
00168
00169 public:
00173 ss_explicit_k std_mem_fun_t(method_type f)
00174 : m_f(f)
00175 {}
00176
00180 return_type operator ()(operand_class_type *pt) const
00181 {
00182 return (pt->*m_f)();
00183 }
00184
00185 private:
00186 method_type m_f;
00187 };
00188
00190 template <class R, class T>
00191 inline std_mem_fun_t<R, T> std_mem_fun(R (STDAPICALLTYPE T::*f)())
00192 {
00193 return std_mem_fun_t<R, T>(f);
00194 }
00195
00202 template< ss_typename_param_k R
00203 , ss_typename_param_k T
00204 >
00205 class std_mem_fun_ref_t
00206 : public comstl_ns_qual_std(unary_function)<T&, R>
00207 {
00208 public:
00209 typedef R return_type;
00210 typedef T operand_class_type;
00211 typedef return_type (STDAPICALLTYPE T::*method_type)();
00212
00213 public:
00217 ss_explicit_k std_mem_fun_ref_t(method_type f)
00218 : m_f(f)
00219 {}
00220
00224 return_type operator ()(operand_class_type &t) const
00225 {
00226 return (t.*m_f)();
00227 }
00228
00229 private:
00230 method_type m_f;
00231 };
00232
00234 template <class R, class T>
00235 inline std_mem_fun_ref_t<R, T> std_mem_fun_ref(R (STDAPICALLTYPE T::*f)())
00236 {
00237 return std_mem_fun_ref_t<R, T>(f);
00238 }
00239
00240
00245 struct BSTR_close
00246 : public comstl_ns_qual_std(unary_function)<BSTR, void>
00247 {
00251 void operator ()(BSTR s) const
00252 {
00253 ::SysFreeString(s);
00254 }
00255 };
00256
00261 struct olestring_close
00262 : public comstl_ns_qual_std(unary_function)<LPOLESTR, void>
00263 {
00267 void operator ()(LPOLESTR s) const
00268 {
00269 ::CoTaskMemFree(s);
00270 }
00271 };
00272
00277 struct task_memory_close
00278 : public comstl_ns_qual_std(unary_function)<void *, void>
00279 {
00283 void operator ()(void *p) const
00284 {
00285 ::CoTaskMemFree(p);
00286 }
00287 };
00288
00293 struct VARIANT_close
00294 : public comstl_ns_qual_std(unary_function)<VARIANT&, void>
00295 {
00299 void operator ()(VARIANT &v) const
00300 {
00301 ::VariantClear(&v);
00302 }
00303 };
00304
00306
00307
00308 #ifdef STLSOFT_UNITTEST
00309
00310 namespace unittest
00311 {
00312 ss_bool_t test_comstl_functionals(unittest_reporter *r)
00313 {
00314 using stlsoft::unittest::unittest_initialiser;
00315
00316 ss_bool_t bSuccess = true;
00317
00318 unittest_initialiser init(r, "COMSTL", "functionals", __FILE__);
00319
00320 #if 0
00321 if(<<TODO>>)
00322 {
00323 r->report("<<TODO>> failed ", __LINE__);
00324 bSuccess = false;
00325 }
00326 #endif
00327
00328 return bSuccess;
00329 }
00330
00331 unittest_registrar unittest_comstl_functionals(test_comstl_functionals);
00332
00333 }
00334
00335 #endif
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347 #endif
00348
00349
00350
00351
00352
00353