1 #ifndef BOOST_MEM_FN_HPP_INCLUDED
2 #define BOOST_MEM_FN_HPP_INCLUDED
9 // mem_fn.hpp - a generalization of std::mem_fun[_ref]
11 // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
12 // Copyright (c) 2001 David Abrahams
14 // Permission to copy, use, modify, sell and distribute this software
15 // is granted provided this copyright notice appears in all copies.
16 // This software is provided "as is" without express or implied
17 // warranty, and with no claim as to its suitability for any purpose.
19 // See http://www.boost.org/libs/bind/mem_fn.html for documentation.
22 #include <boost/config.hpp>
23 #include <boost/get_pointer.hpp>
28 #if defined(BOOST_NO_VOID_RETURNS)
30 #define BOOST_MEM_FN_CLASS_F , class F
31 #define BOOST_MEM_FN_TYPEDEF(X)
33 namespace _mfi // mem_fun_impl
36 template<class V> struct mf
39 #define BOOST_MEM_FN_RETURN return
41 #define BOOST_MEM_FN_NAME(X) inner_##X
42 #define BOOST_MEM_FN_CC
44 #include <boost/bind/mem_fn_template.hpp>
46 #undef BOOST_MEM_FN_CC
47 #undef BOOST_MEM_FN_NAME
49 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
51 #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
52 #define BOOST_MEM_FN_CC __stdcall
54 #include <boost/bind/mem_fn_template.hpp>
56 #undef BOOST_MEM_FN_CC
57 #undef BOOST_MEM_FN_NAME
61 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
63 #define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
64 #define BOOST_MEM_FN_CC __fastcall
66 #include <boost/bind/mem_fn_template.hpp>
68 #undef BOOST_MEM_FN_CC
69 #undef BOOST_MEM_FN_NAME
73 #undef BOOST_MEM_FN_RETURN
77 template<> struct mf<void>
80 #define BOOST_MEM_FN_RETURN
82 #define BOOST_MEM_FN_NAME(X) inner_##X
83 #define BOOST_MEM_FN_CC
85 #include <boost/bind/mem_fn_template.hpp>
87 #undef BOOST_MEM_FN_CC
88 #undef BOOST_MEM_FN_NAME
90 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
92 #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
93 #define BOOST_MEM_FN_CC __stdcall
95 #include <boost/bind/mem_fn_template.hpp>
97 #undef BOOST_MEM_FN_CC
98 #undef BOOST_MEM_FN_NAME
102 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
104 #define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
105 #define BOOST_MEM_FN_CC __fastcall
107 #include <boost/bind/mem_fn_template.hpp>
109 #undef BOOST_MEM_FN_CC
110 #undef BOOST_MEM_FN_NAME
114 #undef BOOST_MEM_FN_RETURN
116 }; // struct mf<void>
118 #undef BOOST_MEM_FN_CLASS_F
119 #undef BOOST_MEM_FN_TYPEDEF_F
121 #define BOOST_MEM_FN_NAME(X) X
122 #define BOOST_MEM_FN_NAME2(X) inner_##X
123 #define BOOST_MEM_FN_CC
125 #include <boost/bind/mem_fn_vw.hpp>
127 #undef BOOST_MEM_FN_NAME
128 #undef BOOST_MEM_FN_NAME2
129 #undef BOOST_MEM_FN_CC
131 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
133 #define BOOST_MEM_FN_NAME(X) X##_stdcall
134 #define BOOST_MEM_FN_NAME2(X) inner_##X##_stdcall
135 #define BOOST_MEM_FN_CC __stdcall
137 #include <boost/bind/mem_fn_vw.hpp>
139 #undef BOOST_MEM_FN_NAME
140 #undef BOOST_MEM_FN_NAME2
141 #undef BOOST_MEM_FN_CC
145 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
147 #define BOOST_MEM_FN_NAME(X) X##_fastcall
148 #define BOOST_MEM_FN_NAME2(X) inner_##X##_fastcall
149 #define BOOST_MEM_FN_CC __fastcall
151 #include <boost/bind/mem_fn_vw.hpp>
153 #undef BOOST_MEM_FN_NAME
154 #undef BOOST_MEM_FN_NAME2
155 #undef BOOST_MEM_FN_CC
161 #else // #ifdef BOOST_NO_VOID_RETURNS
163 #define BOOST_MEM_FN_CLASS_F
164 #define BOOST_MEM_FN_TYPEDEF(X) typedef X;
169 #define BOOST_MEM_FN_RETURN return
171 #define BOOST_MEM_FN_NAME(X) X
172 #define BOOST_MEM_FN_CC
174 #include <boost/bind/mem_fn_template.hpp>
176 #undef BOOST_MEM_FN_CC
177 #undef BOOST_MEM_FN_NAME
179 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
181 #define BOOST_MEM_FN_NAME(X) X##_stdcall
182 #define BOOST_MEM_FN_CC __stdcall
184 #include <boost/bind/mem_fn_template.hpp>
186 #undef BOOST_MEM_FN_CC
187 #undef BOOST_MEM_FN_NAME
191 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
193 #define BOOST_MEM_FN_NAME(X) X##_fastcall
194 #define BOOST_MEM_FN_CC __fastcall
196 #include <boost/bind/mem_fn_template.hpp>
198 #undef BOOST_MEM_FN_CC
199 #undef BOOST_MEM_FN_NAME
203 #undef BOOST_MEM_FN_RETURN
207 #undef BOOST_MEM_FN_CLASS_F
208 #undef BOOST_MEM_FN_TYPEDEF
210 #endif // #ifdef BOOST_NO_VOID_RETURNS
212 #define BOOST_MEM_FN_NAME(X) X
213 #define BOOST_MEM_FN_CC
215 #include <boost/bind/mem_fn_cc.hpp>
217 #undef BOOST_MEM_FN_NAME
218 #undef BOOST_MEM_FN_CC
220 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
222 #define BOOST_MEM_FN_NAME(X) X##_stdcall
223 #define BOOST_MEM_FN_CC __stdcall
225 #include <boost/bind/mem_fn_cc.hpp>
227 #undef BOOST_MEM_FN_NAME
228 #undef BOOST_MEM_FN_CC
232 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
234 #define BOOST_MEM_FN_NAME(X) X##_fastcall
235 #define BOOST_MEM_FN_CC __fastcall
237 #include <boost/bind/mem_fn_cc.hpp>
239 #undef BOOST_MEM_FN_NAME
240 #undef BOOST_MEM_FN_CC
244 // data member support
249 template<class R, class T> class dm
253 typedef R const & result_type;
254 typedef T const * argument_type;
261 template<class U> R const & call(U & u, T const *) const
266 template<class U> R & call(U & u, T *) const
271 template<class U> R const & call(U & u, void const *) const
273 return (get_pointer(u)->*f_);
278 explicit dm(F f): f_(f) {}
280 R & operator()(T * p) const
285 R const & operator()(T const * p) const
290 template<class U> R const & operator()(U & u) const
295 #if !defined(BOOST_MSVC) || (BOOST_MSVC > 1300)
297 R & operator()(T & t) const
304 R const & operator()(T const & t) const
312 template<class R, class T> _mfi::dm<R, T> mem_fn(R T::*f)
314 return _mfi::dm<R, T>(f);
319 #endif // #ifndef BOOST_MEM_FN_HPP_INCLUDED