1 #ifndef BOOST_BIND_MEM_FN_HPP_INCLUDED
\r
2 #define BOOST_BIND_MEM_FN_HPP_INCLUDED
\r
4 // MS compatible compilers support #pragma once
\r
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
\r
11 // mem_fn.hpp - a generalization of std::mem_fun[_ref]
\r
13 // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
\r
14 // Copyright (c) 2001 David Abrahams
\r
15 // Copyright (c) 2003-2005 Peter Dimov
\r
17 // Distributed under the Boost Software License, Version 1.0. (See
\r
18 // accompanying file LICENSE_1_0.txt or copy at
\r
19 // http://www.boost.org/LICENSE_1_0.txt)
\r
21 // See http://www.boost.org/libs/bind/mem_fn.html for documentation.
\r
24 #include <boost/config.hpp>
\r
25 #include <boost/get_pointer.hpp>
\r
26 #include <boost/detail/workaround.hpp>
\r
31 #if defined(BOOST_NO_VOID_RETURNS)
\r
33 #define BOOST_MEM_FN_CLASS_F , class F
\r
34 #define BOOST_MEM_FN_TYPEDEF(X)
\r
36 namespace _mfi // mem_fun_impl
\r
39 template<class V> struct mf
\r
42 #define BOOST_MEM_FN_RETURN return
\r
44 #define BOOST_MEM_FN_NAME(X) inner_##X
\r
45 #define BOOST_MEM_FN_CC
\r
47 #include <boost/bind/mem_fn_template.hpp>
\r
49 #undef BOOST_MEM_FN_CC
\r
50 #undef BOOST_MEM_FN_NAME
\r
52 #ifdef BOOST_MEM_FN_ENABLE_CDECL
\r
54 #define BOOST_MEM_FN_NAME(X) inner_##X##_cdecl
\r
55 #define BOOST_MEM_FN_CC __cdecl
\r
57 #include <boost/bind/mem_fn_template.hpp>
\r
59 #undef BOOST_MEM_FN_CC
\r
60 #undef BOOST_MEM_FN_NAME
\r
64 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
\r
66 #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
\r
67 #define BOOST_MEM_FN_CC __stdcall
\r
69 #include <boost/bind/mem_fn_template.hpp>
\r
71 #undef BOOST_MEM_FN_CC
\r
72 #undef BOOST_MEM_FN_NAME
\r
76 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
\r
78 #define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
\r
79 #define BOOST_MEM_FN_CC __fastcall
\r
81 #include <boost/bind/mem_fn_template.hpp>
\r
83 #undef BOOST_MEM_FN_CC
\r
84 #undef BOOST_MEM_FN_NAME
\r
88 #undef BOOST_MEM_FN_RETURN
\r
92 template<> struct mf<void>
\r
95 #define BOOST_MEM_FN_RETURN
\r
97 #define BOOST_MEM_FN_NAME(X) inner_##X
\r
98 #define BOOST_MEM_FN_CC
\r
100 #include <boost/bind/mem_fn_template.hpp>
\r
102 #undef BOOST_MEM_FN_CC
\r
103 #undef BOOST_MEM_FN_NAME
\r
105 #ifdef BOOST_MEM_FN_ENABLE_CDECL
\r
107 #define BOOST_MEM_FN_NAME(X) inner_##X##_cdecl
\r
108 #define BOOST_MEM_FN_CC __cdecl
\r
110 #include <boost/bind/mem_fn_template.hpp>
\r
112 #undef BOOST_MEM_FN_CC
\r
113 #undef BOOST_MEM_FN_NAME
\r
117 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
\r
119 #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
\r
120 #define BOOST_MEM_FN_CC __stdcall
\r
122 #include <boost/bind/mem_fn_template.hpp>
\r
124 #undef BOOST_MEM_FN_CC
\r
125 #undef BOOST_MEM_FN_NAME
\r
129 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
\r
131 #define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
\r
132 #define BOOST_MEM_FN_CC __fastcall
\r
134 #include <boost/bind/mem_fn_template.hpp>
\r
136 #undef BOOST_MEM_FN_CC
\r
137 #undef BOOST_MEM_FN_NAME
\r
141 #undef BOOST_MEM_FN_RETURN
\r
143 }; // struct mf<void>
\r
145 #undef BOOST_MEM_FN_CLASS_F
\r
146 #undef BOOST_MEM_FN_TYPEDEF_F
\r
148 #define BOOST_MEM_FN_NAME(X) X
\r
149 #define BOOST_MEM_FN_NAME2(X) inner_##X
\r
150 #define BOOST_MEM_FN_CC
\r
152 #include <boost/bind/mem_fn_vw.hpp>
\r
154 #undef BOOST_MEM_FN_NAME
\r
155 #undef BOOST_MEM_FN_NAME2
\r
156 #undef BOOST_MEM_FN_CC
\r
158 #ifdef BOOST_MEM_FN_ENABLE_CDECL
\r
160 #define BOOST_MEM_FN_NAME(X) X##_cdecl
\r
161 #define BOOST_MEM_FN_NAME2(X) inner_##X##_cdecl
\r
162 #define BOOST_MEM_FN_CC __cdecl
\r
164 #include <boost/bind/mem_fn_vw.hpp>
\r
166 #undef BOOST_MEM_FN_NAME
\r
167 #undef BOOST_MEM_FN_NAME2
\r
168 #undef BOOST_MEM_FN_CC
\r
172 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
\r
174 #define BOOST_MEM_FN_NAME(X) X##_stdcall
\r
175 #define BOOST_MEM_FN_NAME2(X) inner_##X##_stdcall
\r
176 #define BOOST_MEM_FN_CC __stdcall
\r
178 #include <boost/bind/mem_fn_vw.hpp>
\r
180 #undef BOOST_MEM_FN_NAME
\r
181 #undef BOOST_MEM_FN_NAME2
\r
182 #undef BOOST_MEM_FN_CC
\r
186 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
\r
188 #define BOOST_MEM_FN_NAME(X) X##_fastcall
\r
189 #define BOOST_MEM_FN_NAME2(X) inner_##X##_fastcall
\r
190 #define BOOST_MEM_FN_CC __fastcall
\r
192 #include <boost/bind/mem_fn_vw.hpp>
\r
194 #undef BOOST_MEM_FN_NAME
\r
195 #undef BOOST_MEM_FN_NAME2
\r
196 #undef BOOST_MEM_FN_CC
\r
200 } // namespace _mfi
\r
202 #else // #ifdef BOOST_NO_VOID_RETURNS
\r
204 #define BOOST_MEM_FN_CLASS_F
\r
205 #define BOOST_MEM_FN_TYPEDEF(X) typedef X;
\r
210 #define BOOST_MEM_FN_RETURN return
\r
212 #define BOOST_MEM_FN_NAME(X) X
\r
213 #define BOOST_MEM_FN_CC
\r
215 #include <boost/bind/mem_fn_template.hpp>
\r
217 #undef BOOST_MEM_FN_CC
\r
218 #undef BOOST_MEM_FN_NAME
\r
220 #ifdef BOOST_MEM_FN_ENABLE_CDECL
\r
222 #define BOOST_MEM_FN_NAME(X) X##_cdecl
\r
223 #define BOOST_MEM_FN_CC __cdecl
\r
225 #include <boost/bind/mem_fn_template.hpp>
\r
227 #undef BOOST_MEM_FN_CC
\r
228 #undef BOOST_MEM_FN_NAME
\r
232 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
\r
234 #define BOOST_MEM_FN_NAME(X) X##_stdcall
\r
235 #define BOOST_MEM_FN_CC __stdcall
\r
237 #include <boost/bind/mem_fn_template.hpp>
\r
239 #undef BOOST_MEM_FN_CC
\r
240 #undef BOOST_MEM_FN_NAME
\r
244 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
\r
246 #define BOOST_MEM_FN_NAME(X) X##_fastcall
\r
247 #define BOOST_MEM_FN_CC __fastcall
\r
249 #include <boost/bind/mem_fn_template.hpp>
\r
251 #undef BOOST_MEM_FN_CC
\r
252 #undef BOOST_MEM_FN_NAME
\r
256 #undef BOOST_MEM_FN_RETURN
\r
258 } // namespace _mfi
\r
260 #undef BOOST_MEM_FN_CLASS_F
\r
261 #undef BOOST_MEM_FN_TYPEDEF
\r
263 #endif // #ifdef BOOST_NO_VOID_RETURNS
\r
265 #define BOOST_MEM_FN_NAME(X) X
\r
266 #define BOOST_MEM_FN_CC
\r
268 #include <boost/bind/mem_fn_cc.hpp>
\r
270 #undef BOOST_MEM_FN_NAME
\r
271 #undef BOOST_MEM_FN_CC
\r
273 #ifdef BOOST_MEM_FN_ENABLE_CDECL
\r
275 #define BOOST_MEM_FN_NAME(X) X##_cdecl
\r
276 #define BOOST_MEM_FN_CC __cdecl
\r
278 #include <boost/bind/mem_fn_cc.hpp>
\r
280 #undef BOOST_MEM_FN_NAME
\r
281 #undef BOOST_MEM_FN_CC
\r
285 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
\r
287 #define BOOST_MEM_FN_NAME(X) X##_stdcall
\r
288 #define BOOST_MEM_FN_CC __stdcall
\r
290 #include <boost/bind/mem_fn_cc.hpp>
\r
292 #undef BOOST_MEM_FN_NAME
\r
293 #undef BOOST_MEM_FN_CC
\r
297 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
\r
299 #define BOOST_MEM_FN_NAME(X) X##_fastcall
\r
300 #define BOOST_MEM_FN_CC __fastcall
\r
302 #include <boost/bind/mem_fn_cc.hpp>
\r
304 #undef BOOST_MEM_FN_NAME
\r
305 #undef BOOST_MEM_FN_CC
\r
309 // data member support
\r
314 template<class R, class T> class dm
\r
318 typedef R const & result_type;
\r
319 typedef T const * argument_type;
\r
326 template<class U> R const & call(U & u, T const *) const
\r
331 template<class U> R const & call(U & u, void const *) const
\r
333 return (get_pointer(u)->*f_);
\r
338 explicit dm(F f): f_(f) {}
\r
340 R & operator()(T * p) const
\r
345 R const & operator()(T const * p) const
\r
350 template<class U> R const & operator()(U const & u) const
\r
352 return call(u, &u);
\r
355 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) && !BOOST_WORKAROUND(__MWERKS__, < 0x3200)
\r
357 R & operator()(T & t) const
\r
362 R const & operator()(T const & t) const
\r
369 bool operator==(dm const & rhs) const
\r
371 return f_ == rhs.f_;
\r
374 bool operator!=(dm const & rhs) const
\r
376 return f_ != rhs.f_;
\r
380 } // namespace _mfi
\r
382 template<class R, class T> _mfi::dm<R, T> mem_fn(R T::*f)
\r
384 return _mfi::dm<R, T>(f);
\r
387 } // namespace boost
\r
389 #endif // #ifndef BOOST_BIND_MEM_FN_HPP_INCLUDED
\r