1 #ifndef BOOST_MEM_FN_HPP_INCLUDED
2 #define BOOST_MEM_FN_HPP_INCLUDED
4 // MS compatible compilers support #pragma once
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
11 // mem_fn.hpp - a generalization of std::mem_fun[_ref]
13 // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
14 // Copyright (c) 2001 David Abrahams
16 // Distributed under the Boost Software License, Version 1.0. (See
17 // accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
20 // See http://www.boost.org/libs/bind/mem_fn.html for documentation.
23 #include <boost/config.hpp>
24 #include <boost/get_pointer.hpp>
25 #include <boost/detail/workaround.hpp>
30 #if defined(BOOST_NO_VOID_RETURNS)
32 #define BOOST_MEM_FN_CLASS_F , class F
33 #define BOOST_MEM_FN_TYPEDEF(X)
35 namespace _mfi // mem_fun_impl
38 template<class V> struct mf
41 #define BOOST_MEM_FN_RETURN return
43 #define BOOST_MEM_FN_NAME(X) inner_##X
44 #define BOOST_MEM_FN_CC
46 #include <boost/bind/mem_fn_template.hpp>
48 #undef BOOST_MEM_FN_CC
49 #undef BOOST_MEM_FN_NAME
51 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
53 #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
54 #define BOOST_MEM_FN_CC __stdcall
56 #include <boost/bind/mem_fn_template.hpp>
58 #undef BOOST_MEM_FN_CC
59 #undef BOOST_MEM_FN_NAME
63 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
65 #define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
66 #define BOOST_MEM_FN_CC __fastcall
68 #include <boost/bind/mem_fn_template.hpp>
70 #undef BOOST_MEM_FN_CC
71 #undef BOOST_MEM_FN_NAME
75 #undef BOOST_MEM_FN_RETURN
79 template<> struct mf<void>
82 #define BOOST_MEM_FN_RETURN
84 #define BOOST_MEM_FN_NAME(X) inner_##X
85 #define BOOST_MEM_FN_CC
87 #include <boost/bind/mem_fn_template.hpp>
89 #undef BOOST_MEM_FN_CC
90 #undef BOOST_MEM_FN_NAME
92 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
94 #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
95 #define BOOST_MEM_FN_CC __stdcall
97 #include <boost/bind/mem_fn_template.hpp>
99 #undef BOOST_MEM_FN_CC
100 #undef BOOST_MEM_FN_NAME
104 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
106 #define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
107 #define BOOST_MEM_FN_CC __fastcall
109 #include <boost/bind/mem_fn_template.hpp>
111 #undef BOOST_MEM_FN_CC
112 #undef BOOST_MEM_FN_NAME
116 #undef BOOST_MEM_FN_RETURN
118 }; // struct mf<void>
120 #undef BOOST_MEM_FN_CLASS_F
121 #undef BOOST_MEM_FN_TYPEDEF_F
123 #define BOOST_MEM_FN_NAME(X) X
124 #define BOOST_MEM_FN_NAME2(X) inner_##X
125 #define BOOST_MEM_FN_CC
127 #include <boost/bind/mem_fn_vw.hpp>
129 #undef BOOST_MEM_FN_NAME
130 #undef BOOST_MEM_FN_NAME2
131 #undef BOOST_MEM_FN_CC
133 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
135 #define BOOST_MEM_FN_NAME(X) X##_stdcall
136 #define BOOST_MEM_FN_NAME2(X) inner_##X##_stdcall
137 #define BOOST_MEM_FN_CC __stdcall
139 #include <boost/bind/mem_fn_vw.hpp>
141 #undef BOOST_MEM_FN_NAME
142 #undef BOOST_MEM_FN_NAME2
143 #undef BOOST_MEM_FN_CC
147 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
149 #define BOOST_MEM_FN_NAME(X) X##_fastcall
150 #define BOOST_MEM_FN_NAME2(X) inner_##X##_fastcall
151 #define BOOST_MEM_FN_CC __fastcall
153 #include <boost/bind/mem_fn_vw.hpp>
155 #undef BOOST_MEM_FN_NAME
156 #undef BOOST_MEM_FN_NAME2
157 #undef BOOST_MEM_FN_CC
163 #else // #ifdef BOOST_NO_VOID_RETURNS
165 #define BOOST_MEM_FN_CLASS_F
166 #define BOOST_MEM_FN_TYPEDEF(X) typedef X;
171 #define BOOST_MEM_FN_RETURN return
173 #define BOOST_MEM_FN_NAME(X) X
174 #define BOOST_MEM_FN_CC
176 #include <boost/bind/mem_fn_template.hpp>
178 #undef BOOST_MEM_FN_CC
179 #undef BOOST_MEM_FN_NAME
181 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
183 #define BOOST_MEM_FN_NAME(X) X##_stdcall
184 #define BOOST_MEM_FN_CC __stdcall
186 #include <boost/bind/mem_fn_template.hpp>
188 #undef BOOST_MEM_FN_CC
189 #undef BOOST_MEM_FN_NAME
193 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
195 #define BOOST_MEM_FN_NAME(X) X##_fastcall
196 #define BOOST_MEM_FN_CC __fastcall
198 #include <boost/bind/mem_fn_template.hpp>
200 #undef BOOST_MEM_FN_CC
201 #undef BOOST_MEM_FN_NAME
205 #undef BOOST_MEM_FN_RETURN
209 #undef BOOST_MEM_FN_CLASS_F
210 #undef BOOST_MEM_FN_TYPEDEF
212 #endif // #ifdef BOOST_NO_VOID_RETURNS
214 #define BOOST_MEM_FN_NAME(X) X
215 #define BOOST_MEM_FN_CC
217 #include <boost/bind/mem_fn_cc.hpp>
219 #undef BOOST_MEM_FN_NAME
220 #undef BOOST_MEM_FN_CC
222 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
224 #define BOOST_MEM_FN_NAME(X) X##_stdcall
225 #define BOOST_MEM_FN_CC __stdcall
227 #include <boost/bind/mem_fn_cc.hpp>
229 #undef BOOST_MEM_FN_NAME
230 #undef BOOST_MEM_FN_CC
234 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
236 #define BOOST_MEM_FN_NAME(X) X##_fastcall
237 #define BOOST_MEM_FN_CC __fastcall
239 #include <boost/bind/mem_fn_cc.hpp>
241 #undef BOOST_MEM_FN_NAME
242 #undef BOOST_MEM_FN_CC
246 // data member support
251 template<class R, class T> class dm
255 typedef R const & result_type;
256 typedef T const * argument_type;
263 template<class U> R const & call(U & u, T const *) const
268 template<class U> R & call(U & u, T *) const
273 template<class U> R const & call(U & u, void const *) const
275 return (get_pointer(u)->*f_);
280 explicit dm(F f): f_(f) {}
282 R & operator()(T * p) const
287 R const & operator()(T const * p) const
292 template<class U> R const & operator()(U & u) const
297 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) && !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
299 R & operator()(T & t) const
306 R const & operator()(T const & t) const
311 bool operator==(dm const & rhs) const
316 bool operator!=(dm const & rhs) const
324 template<class R, class T> _mfi::dm<R, T> mem_fn(R T::*f)
326 return _mfi::dm<R, T>(f);
331 #endif // #ifndef BOOST_MEM_FN_HPP_INCLUDED