1 #ifndef BOOST_BIND_MEM_FN_HPP_INCLUDED
2 #define BOOST_BIND_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
15 // Copyright (c) 2003-2005 Peter Dimov
17 // Distributed under the Boost Software License, Version 1.0. (See
18 // accompanying file LICENSE_1_0.txt or copy at
19 // http://www.boost.org/LICENSE_1_0.txt)
21 // See http://www.boost.org/libs/bind/mem_fn.html for documentation.
24 #include <boost/config.hpp>
25 #include <boost/get_pointer.hpp>
26 #include <boost/detail/workaround.hpp>
31 #if defined(BOOST_NO_VOID_RETURNS)
33 #define BOOST_MEM_FN_CLASS_F , class F
34 #define BOOST_MEM_FN_TYPEDEF(X)
36 namespace _mfi // mem_fun_impl
39 template<class V> struct mf
42 #define BOOST_MEM_FN_RETURN return
44 #define BOOST_MEM_FN_NAME(X) inner_##X
45 #define BOOST_MEM_FN_CC
47 #include <boost/bind/mem_fn_template.hpp>
49 #undef BOOST_MEM_FN_CC
50 #undef BOOST_MEM_FN_NAME
52 #if defined(BOOST_MEM_FN_ENABLE_CDECL) && !defined(_M_X64)
54 #define BOOST_MEM_FN_NAME(X) inner_##X##_cdecl
55 #define BOOST_MEM_FN_CC __cdecl
57 #include <boost/bind/mem_fn_template.hpp>
59 #undef BOOST_MEM_FN_CC
60 #undef BOOST_MEM_FN_NAME
64 #if defined(BOOST_MEM_FN_ENABLE_STDCALL) && !defined(_M_X64)
66 #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
67 #define BOOST_MEM_FN_CC __stdcall
69 #include <boost/bind/mem_fn_template.hpp>
71 #undef BOOST_MEM_FN_CC
72 #undef BOOST_MEM_FN_NAME
76 #if defined(BOOST_MEM_FN_ENABLE_FASTCALL) && !defined(_M_X64)
78 #define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
79 #define BOOST_MEM_FN_CC __fastcall
81 #include <boost/bind/mem_fn_template.hpp>
83 #undef BOOST_MEM_FN_CC
84 #undef BOOST_MEM_FN_NAME
88 #undef BOOST_MEM_FN_RETURN
92 template<> struct mf<void>
95 #define BOOST_MEM_FN_RETURN
97 #define BOOST_MEM_FN_NAME(X) inner_##X
98 #define BOOST_MEM_FN_CC
100 #include <boost/bind/mem_fn_template.hpp>
102 #undef BOOST_MEM_FN_CC
103 #undef BOOST_MEM_FN_NAME
105 #if defined(BOOST_MEM_FN_ENABLE_CDECL) && !defined(_M_X64)
107 #define BOOST_MEM_FN_NAME(X) inner_##X##_cdecl
108 #define BOOST_MEM_FN_CC __cdecl
110 #include <boost/bind/mem_fn_template.hpp>
112 #undef BOOST_MEM_FN_CC
113 #undef BOOST_MEM_FN_NAME
117 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
119 #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
120 #define BOOST_MEM_FN_CC __stdcall
122 #include <boost/bind/mem_fn_template.hpp>
124 #undef BOOST_MEM_FN_CC
125 #undef BOOST_MEM_FN_NAME
129 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
131 #define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
132 #define BOOST_MEM_FN_CC __fastcall
134 #include <boost/bind/mem_fn_template.hpp>
136 #undef BOOST_MEM_FN_CC
137 #undef BOOST_MEM_FN_NAME
141 #undef BOOST_MEM_FN_RETURN
143 }; // struct mf<void>
145 #undef BOOST_MEM_FN_CLASS_F
146 #undef BOOST_MEM_FN_TYPEDEF_F
148 #define BOOST_MEM_FN_NAME(X) X
149 #define BOOST_MEM_FN_NAME2(X) inner_##X
150 #define BOOST_MEM_FN_CC
152 #include <boost/bind/mem_fn_vw.hpp>
154 #undef BOOST_MEM_FN_NAME
155 #undef BOOST_MEM_FN_NAME2
156 #undef BOOST_MEM_FN_CC
158 #if defined(BOOST_MEM_FN_ENABLE_CDECL) && !defined(_M_X64)
160 #define BOOST_MEM_FN_NAME(X) X##_cdecl
161 #define BOOST_MEM_FN_NAME2(X) inner_##X##_cdecl
162 #define BOOST_MEM_FN_CC __cdecl
164 #include <boost/bind/mem_fn_vw.hpp>
166 #undef BOOST_MEM_FN_NAME
167 #undef BOOST_MEM_FN_NAME2
168 #undef BOOST_MEM_FN_CC
172 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
174 #define BOOST_MEM_FN_NAME(X) X##_stdcall
175 #define BOOST_MEM_FN_NAME2(X) inner_##X##_stdcall
176 #define BOOST_MEM_FN_CC __stdcall
178 #include <boost/bind/mem_fn_vw.hpp>
180 #undef BOOST_MEM_FN_NAME
181 #undef BOOST_MEM_FN_NAME2
182 #undef BOOST_MEM_FN_CC
186 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
188 #define BOOST_MEM_FN_NAME(X) X##_fastcall
189 #define BOOST_MEM_FN_NAME2(X) inner_##X##_fastcall
190 #define BOOST_MEM_FN_CC __fastcall
192 #include <boost/bind/mem_fn_vw.hpp>
194 #undef BOOST_MEM_FN_NAME
195 #undef BOOST_MEM_FN_NAME2
196 #undef BOOST_MEM_FN_CC
202 #else // #ifdef BOOST_NO_VOID_RETURNS
204 #define BOOST_MEM_FN_CLASS_F
205 #define BOOST_MEM_FN_TYPEDEF(X) typedef X;
210 #define BOOST_MEM_FN_RETURN return
212 #define BOOST_MEM_FN_NAME(X) X
213 #define BOOST_MEM_FN_CC
215 #include <boost/bind/mem_fn_template.hpp>
217 #undef BOOST_MEM_FN_CC
218 #undef BOOST_MEM_FN_NAME
220 #if defined(BOOST_MEM_FN_ENABLE_CDECL) && !defined(_M_X64)
222 #define BOOST_MEM_FN_NAME(X) X##_cdecl
223 #define BOOST_MEM_FN_CC __cdecl
225 #include <boost/bind/mem_fn_template.hpp>
227 #undef BOOST_MEM_FN_CC
228 #undef BOOST_MEM_FN_NAME
232 #if defined(BOOST_MEM_FN_ENABLE_STDCALL) && !defined(_M_X64)
234 #define BOOST_MEM_FN_NAME(X) X##_stdcall
235 #define BOOST_MEM_FN_CC __stdcall
237 #include <boost/bind/mem_fn_template.hpp>
239 #undef BOOST_MEM_FN_CC
240 #undef BOOST_MEM_FN_NAME
244 #if defined(BOOST_MEM_FN_ENABLE_FASTCALL) && !defined(_M_X64)
246 #define BOOST_MEM_FN_NAME(X) X##_fastcall
247 #define BOOST_MEM_FN_CC __fastcall
249 #include <boost/bind/mem_fn_template.hpp>
251 #undef BOOST_MEM_FN_CC
252 #undef BOOST_MEM_FN_NAME
256 #undef BOOST_MEM_FN_RETURN
260 #undef BOOST_MEM_FN_CLASS_F
261 #undef BOOST_MEM_FN_TYPEDEF
263 #endif // #ifdef BOOST_NO_VOID_RETURNS
265 #define BOOST_MEM_FN_NAME(X) X
266 #define BOOST_MEM_FN_CC
267 #define BOOST_MEM_FN_NOEXCEPT
269 #include <boost/bind/mem_fn_cc.hpp>
271 #if defined( __cpp_noexcept_function_type ) || defined( _NOEXCEPT_TYPES_SUPPORTED )
272 # undef BOOST_MEM_FN_NOEXCEPT
273 # define BOOST_MEM_FN_NOEXCEPT noexcept
274 # include <boost/bind/mem_fn_cc.hpp>
277 #undef BOOST_MEM_FN_NAME
278 #undef BOOST_MEM_FN_CC
279 #undef BOOST_MEM_FN_NOEXCEPT
281 #if defined(BOOST_MEM_FN_ENABLE_CDECL) && !defined(_M_X64)
283 #define BOOST_MEM_FN_NAME(X) X##_cdecl
284 #define BOOST_MEM_FN_CC __cdecl
285 #define BOOST_MEM_FN_NOEXCEPT
287 #include <boost/bind/mem_fn_cc.hpp>
289 #undef BOOST_MEM_FN_NAME
290 #undef BOOST_MEM_FN_CC
291 #undef BOOST_MEM_FN_NOEXCEPT
295 #if defined(BOOST_MEM_FN_ENABLE_STDCALL) && !defined(_M_X64)
297 #define BOOST_MEM_FN_NAME(X) X##_stdcall
298 #define BOOST_MEM_FN_CC __stdcall
299 #define BOOST_MEM_FN_NOEXCEPT
301 #include <boost/bind/mem_fn_cc.hpp>
303 #undef BOOST_MEM_FN_NAME
304 #undef BOOST_MEM_FN_CC
305 #undef BOOST_MEM_FN_NOEXCEPT
309 #if defined(BOOST_MEM_FN_ENABLE_FASTCALL) && !defined(_M_X64)
311 #define BOOST_MEM_FN_NAME(X) X##_fastcall
312 #define BOOST_MEM_FN_CC __fastcall
313 #define BOOST_MEM_FN_NOEXCEPT
315 #include <boost/bind/mem_fn_cc.hpp>
317 #undef BOOST_MEM_FN_NAME
318 #undef BOOST_MEM_FN_CC
319 #undef BOOST_MEM_FN_NOEXCEPT
323 // data member support
328 template<class R, class T> class dm
332 typedef R const & result_type;
333 typedef T const * argument_type;
340 template<class U> R const & call(U & u, T const *) const
345 template<class U> R const & call(U & u, void const *) const
347 return (get_pointer(u)->*f_);
352 explicit dm(F f): f_(f) {}
354 R & operator()(T * p) const
359 R const & operator()(T const * p) const
364 template<class U> R const & operator()(U const & u) const
369 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) && !BOOST_WORKAROUND(__MWERKS__, < 0x3200)
371 R & operator()(T & t) const
376 R const & operator()(T const & t) const
383 bool operator==(dm const & rhs) const
388 bool operator!=(dm const & rhs) const
396 template<class R, class T> _mfi::dm<R, T> mem_fn(R T::*f)
398 return _mfi::dm<R, T>(f);
403 #endif // #ifndef BOOST_BIND_MEM_FN_HPP_INCLUDED