src/sysc/packages/boost/mem_fn.hpp

Go to the documentation of this file.
00001 #ifndef BOOST_MEM_FN_HPP_INCLUDED
00002 #define BOOST_MEM_FN_HPP_INCLUDED
00003 
00004 #if _MSC_VER+0 >= 1020
00005 #pragma once
00006 #endif
00007 
00008 //
00009 //  mem_fn.hpp - a generalization of std::mem_fun[_ref]
00010 //
00011 //  Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
00012 //  Copyright (c) 2001 David Abrahams
00013 //
00014 //  Permission to copy, use, modify, sell and distribute this software
00015 //  is granted provided this copyright notice appears in all copies.
00016 //  This software is provided "as is" without express or implied
00017 //  warranty, and with no claim as to its suitability for any purpose.
00018 //
00019 //  See http://www.boost.org/libs/bind/mem_fn.html for documentation.
00020 //
00021 
00022 #include <sysc/packages/boost/config.hpp>
00023 
00024 namespace boost
00025 {
00026 
00027 // get_pointer(p) extracts a ->* capable pointer from p
00028 
00029 template<class T> T * get_pointer(T * p)
00030 {
00031     return p;
00032 }
00033 
00034 // get_pointer(shared_ptr<T> const & p) has been moved to shared_ptr.hpp
00035 
00036 #if defined(BOOST_NO_VOID_RETURNS)
00037 
00038 #define BOOST_MEM_FN_CLASS_F , class F
00039 #define BOOST_MEM_FN_TYPEDEF(X)
00040 
00041 namespace _mfi // mem_fun_impl
00042 {
00043 
00044 template<class V> struct mf
00045 {
00046 
00047 #define BOOST_MEM_FN_RETURN return
00048 
00049 #define BOOST_MEM_FN_NAME(X) inner_##X
00050 #define BOOST_MEM_FN_CC
00051 
00052 #include <sysc/packages/boost/bind/mem_fn_template.hpp>
00053 
00054 #undef BOOST_MEM_FN_CC
00055 #undef BOOST_MEM_FN_NAME
00056 
00057 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
00058 
00059 #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
00060 #define BOOST_MEM_FN_CC __stdcall
00061 
00062 #include <sysc/packages/boost/bind/mem_fn_template.hpp>
00063 
00064 #undef BOOST_MEM_FN_CC
00065 #undef BOOST_MEM_FN_NAME
00066 
00067 #endif
00068 
00069 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
00070 
00071 #define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
00072 #define BOOST_MEM_FN_CC __fastcall
00073 
00074 #include <sysc/packages/boost/bind/mem_fn_template.hpp>
00075 
00076 #undef BOOST_MEM_FN_CC
00077 #undef BOOST_MEM_FN_NAME
00078 
00079 #endif
00080 
00081 #undef BOOST_MEM_FN_RETURN
00082 
00083 }; // struct mf<V>
00084 
00085 template<> struct mf<void>
00086 {
00087 
00088 #define BOOST_MEM_FN_RETURN
00089 
00090 #define BOOST_MEM_FN_NAME(X) inner_##X
00091 #define BOOST_MEM_FN_CC
00092 
00093 #include <sysc/packages/boost/bind/mem_fn_template.hpp>
00094 
00095 #undef BOOST_MEM_FN_CC
00096 #undef BOOST_MEM_FN_NAME
00097 
00098 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
00099 
00100 #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
00101 #define BOOST_MEM_FN_CC __stdcall
00102 
00103 #include <sysc/packages/boost/bind/mem_fn_template.hpp>
00104 
00105 #undef BOOST_MEM_FN_CC
00106 #undef BOOST_MEM_FN_NAME
00107 
00108 #endif
00109 
00110 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
00111 
00112 #define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
00113 #define BOOST_MEM_FN_CC __fastcall
00114 
00115 #include <sysc/packages/boost/bind/mem_fn_template.hpp>
00116 
00117 #undef BOOST_MEM_FN_CC
00118 #undef BOOST_MEM_FN_NAME
00119 
00120 #endif
00121 
00122 #undef BOOST_MEM_FN_RETURN
00123 
00124 }; // struct mf<void>
00125 
00126 #undef BOOST_MEM_FN_CLASS_F
00127 #undef BOOST_MEM_FN_TYPEDEF_F
00128 
00129 #define BOOST_MEM_FN_NAME(X) X
00130 #define BOOST_MEM_FN_NAME2(X) inner_##X
00131 #define BOOST_MEM_FN_CC
00132 
00133 #include <sysc/packages/boost/bind/mem_fn_vw.hpp>
00134 
00135 #undef BOOST_MEM_FN_NAME
00136 #undef BOOST_MEM_FN_NAME2
00137 #undef BOOST_MEM_FN_CC
00138 
00139 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
00140 
00141 #define BOOST_MEM_FN_NAME(X) X##_stdcall
00142 #define BOOST_MEM_FN_NAME2(X) inner_##X##_stdcall
00143 #define BOOST_MEM_FN_CC __stdcall
00144 
00145 #include <sysc/packages/boost/bind/mem_fn_vw.hpp>
00146 
00147 #undef BOOST_MEM_FN_NAME
00148 #undef BOOST_MEM_FN_NAME2
00149 #undef BOOST_MEM_FN_CC
00150 
00151 #endif
00152 
00153 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
00154 
00155 #define BOOST_MEM_FN_NAME(X) X##_fastcall
00156 #define BOOST_MEM_FN_NAME2(X) inner_##X##_fastcall
00157 #define BOOST_MEM_FN_CC __fastcall
00158 
00159 #include <sysc/packages/boost/bind/mem_fn_vw.hpp>
00160 
00161 #undef BOOST_MEM_FN_NAME
00162 #undef BOOST_MEM_FN_NAME2
00163 #undef BOOST_MEM_FN_CC
00164 
00165 #endif
00166 
00167 } // namespace _mfi
00168 
00169 #else // #ifdef BOOST_NO_VOID_RETURNS
00170 
00171 #define BOOST_MEM_FN_CLASS_F
00172 #define BOOST_MEM_FN_TYPEDEF(X) typedef X;
00173 
00174 namespace _mfi
00175 {
00176 
00177 #define BOOST_MEM_FN_RETURN return
00178 
00179 #define BOOST_MEM_FN_NAME(X) X
00180 #define BOOST_MEM_FN_CC
00181 
00182 #include <sysc/packages/boost/bind/mem_fn_template.hpp>
00183 
00184 #undef BOOST_MEM_FN_CC
00185 #undef BOOST_MEM_FN_NAME
00186 
00187 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
00188 
00189 #define BOOST_MEM_FN_NAME(X) X##_stdcall
00190 #define BOOST_MEM_FN_CC __stdcall
00191 
00192 #include <sysc/packages/boost/bind/mem_fn_template.hpp>
00193 
00194 #undef BOOST_MEM_FN_CC
00195 #undef BOOST_MEM_FN_NAME
00196 
00197 #endif
00198 
00199 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
00200 
00201 #define BOOST_MEM_FN_NAME(X) X##_fastcall
00202 #define BOOST_MEM_FN_CC __fastcall
00203 
00204 #include <sysc/packages/boost/bind/mem_fn_template.hpp>
00205 
00206 #undef BOOST_MEM_FN_CC
00207 #undef BOOST_MEM_FN_NAME
00208 
00209 #endif
00210 
00211 #undef BOOST_MEM_FN_RETURN
00212 
00213 } // namespace _mfi
00214 
00215 #undef BOOST_MEM_FN_CLASS_F
00216 #undef BOOST_MEM_FN_TYPEDEF
00217 
00218 #endif // #ifdef BOOST_NO_VOID_RETURNS
00219 
00220 #define BOOST_MEM_FN_NAME(X) X
00221 #define BOOST_MEM_FN_CC
00222 
00223 #include <sysc/packages/boost/bind/mem_fn_cc.hpp>
00224 
00225 #undef BOOST_MEM_FN_NAME
00226 #undef BOOST_MEM_FN_CC
00227 
00228 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
00229 
00230 #define BOOST_MEM_FN_NAME(X) X##_stdcall
00231 #define BOOST_MEM_FN_CC __stdcall
00232 
00233 #include <sysc/packages/boost/bind/mem_fn_cc.hpp>
00234 
00235 #undef BOOST_MEM_FN_NAME
00236 #undef BOOST_MEM_FN_CC
00237 
00238 #endif
00239 
00240 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
00241 
00242 #define BOOST_MEM_FN_NAME(X) X##_fastcall
00243 #define BOOST_MEM_FN_CC __fastcall
00244 
00245 #include <sysc/packages/boost/bind/mem_fn_cc.hpp>
00246 
00247 #undef BOOST_MEM_FN_NAME
00248 #undef BOOST_MEM_FN_CC
00249 
00250 #endif
00251 
00252 // data member support
00253 
00254 namespace _mfi
00255 {
00256 
00257 template<class R, class T> class dm
00258 {
00259 public:
00260 
00261     typedef R const & result_type;
00262     typedef T const * argument_type;
00263 
00264 private:
00265     
00266     typedef R (T::*F);
00267     F f_;
00268 
00269     template<class U> R const & call(U & u, T const *) const
00270     {
00271         return (u.*f_);
00272     }
00273 
00274     template<class U> R & call(U & u, T *) const
00275     {
00276         return (u.*f_);
00277     }
00278 
00279     template<class U> R const & call(U & u, void const *) const
00280     {
00281         return (get_pointer(u)->*f_);
00282     }
00283 
00284 public:
00285     
00286     explicit dm(F f): f_(f) {}
00287 
00288     R & operator()(T * p) const
00289     {
00290         return (p->*f_);
00291     }
00292 
00293     R const & operator()(T const * p) const
00294     {
00295         return (p->*f_);
00296     }
00297 
00298     template<class U> R const & operator()(U & u) const
00299     {
00300         return call(u, &u);
00301     }
00302 
00303 #if !defined(BOOST_MSVC) || (BOOST_MSVC > 1300)
00304 
00305     R & operator()(T & t) const
00306     {
00307         return (t.*f_);
00308     }
00309 
00310 #endif
00311 
00312     R const & operator()(T const & t) const
00313     {
00314         return (t.*f_);
00315     }
00316 };
00317 
00318 } // namespace _mfi
00319 
00320 template<class R, class T> _mfi::dm<R, T> mem_fn(R T::*f)
00321 {
00322     return _mfi::dm<R, T>(f);
00323 }
00324 
00325 } // namespace boost
00326 
00327 #endif // #ifndef BOOST_MEM_FN_HPP_INCLUDED

Generated on Wed Apr 25 13:53:28 2007 for SystemC by  doxygen 1.5.1