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 // Permission to copy, use, modify, sell and distribute this software
17 // is granted provided this copyright notice appears in all copies.
18 // This software is provided "as is" without express or implied
19 // warranty, and with no claim as to its suitability for any purpose.
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 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
54 #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
55 #define BOOST_MEM_FN_CC __stdcall
57 #include <boost/bind/mem_fn_template.hpp>
59 #undef BOOST_MEM_FN_CC
60 #undef BOOST_MEM_FN_NAME
64 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
66 #define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
67 #define BOOST_MEM_FN_CC __fastcall
69 #include <boost/bind/mem_fn_template.hpp>
71 #undef BOOST_MEM_FN_CC
72 #undef BOOST_MEM_FN_NAME
76 #undef BOOST_MEM_FN_RETURN
80 template<> struct mf<void>
83 #define BOOST_MEM_FN_RETURN
85 #define BOOST_MEM_FN_NAME(X) inner_##X
86 #define BOOST_MEM_FN_CC
88 #include <boost/bind/mem_fn_template.hpp>
90 #undef BOOST_MEM_FN_CC
91 #undef BOOST_MEM_FN_NAME
93 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
95 #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
96 #define BOOST_MEM_FN_CC __stdcall
98 #include <boost/bind/mem_fn_template.hpp>
100 #undef BOOST_MEM_FN_CC
101 #undef BOOST_MEM_FN_NAME
105 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
107 #define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
108 #define BOOST_MEM_FN_CC __fastcall
110 #include <boost/bind/mem_fn_template.hpp>
112 #undef BOOST_MEM_FN_CC
113 #undef BOOST_MEM_FN_NAME
117 #undef BOOST_MEM_FN_RETURN
119 }; // struct mf<void>
121 #undef BOOST_MEM_FN_CLASS_F
122 #undef BOOST_MEM_FN_TYPEDEF_F
124 #define BOOST_MEM_FN_NAME(X) X
125 #define BOOST_MEM_FN_NAME2(X) inner_##X
126 #define BOOST_MEM_FN_CC
128 #include <boost/bind/mem_fn_vw.hpp>
130 #undef BOOST_MEM_FN_NAME
131 #undef BOOST_MEM_FN_NAME2
132 #undef BOOST_MEM_FN_CC
134 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
136 #define BOOST_MEM_FN_NAME(X) X##_stdcall
137 #define BOOST_MEM_FN_NAME2(X) inner_##X##_stdcall
138 #define BOOST_MEM_FN_CC __stdcall
140 #include <boost/bind/mem_fn_vw.hpp>
142 #undef BOOST_MEM_FN_NAME
143 #undef BOOST_MEM_FN_NAME2
144 #undef BOOST_MEM_FN_CC
148 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
150 #define BOOST_MEM_FN_NAME(X) X##_fastcall
151 #define BOOST_MEM_FN_NAME2(X) inner_##X##_fastcall
152 #define BOOST_MEM_FN_CC __fastcall
154 #include <boost/bind/mem_fn_vw.hpp>
156 #undef BOOST_MEM_FN_NAME
157 #undef BOOST_MEM_FN_NAME2
158 #undef BOOST_MEM_FN_CC
164 #else // #ifdef BOOST_NO_VOID_RETURNS
166 #define BOOST_MEM_FN_CLASS_F
167 #define BOOST_MEM_FN_TYPEDEF(X) typedef X;
172 #define BOOST_MEM_FN_RETURN return
174 #define BOOST_MEM_FN_NAME(X) X
175 #define BOOST_MEM_FN_CC
177 #include <boost/bind/mem_fn_template.hpp>
179 #undef BOOST_MEM_FN_CC
180 #undef BOOST_MEM_FN_NAME
182 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
184 #define BOOST_MEM_FN_NAME(X) X##_stdcall
185 #define BOOST_MEM_FN_CC __stdcall
187 #include <boost/bind/mem_fn_template.hpp>
189 #undef BOOST_MEM_FN_CC
190 #undef BOOST_MEM_FN_NAME
194 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
196 #define BOOST_MEM_FN_NAME(X) X##_fastcall
197 #define BOOST_MEM_FN_CC __fastcall
199 #include <boost/bind/mem_fn_template.hpp>
201 #undef BOOST_MEM_FN_CC
202 #undef BOOST_MEM_FN_NAME
206 #undef BOOST_MEM_FN_RETURN
210 #undef BOOST_MEM_FN_CLASS_F
211 #undef BOOST_MEM_FN_TYPEDEF
213 #endif // #ifdef BOOST_NO_VOID_RETURNS
215 #define BOOST_MEM_FN_NAME(X) X
216 #define BOOST_MEM_FN_CC
218 #include <boost/bind/mem_fn_cc.hpp>
220 #undef BOOST_MEM_FN_NAME
221 #undef BOOST_MEM_FN_CC
223 #ifdef BOOST_MEM_FN_ENABLE_STDCALL
225 #define BOOST_MEM_FN_NAME(X) X##_stdcall
226 #define BOOST_MEM_FN_CC __stdcall
228 #include <boost/bind/mem_fn_cc.hpp>
230 #undef BOOST_MEM_FN_NAME
231 #undef BOOST_MEM_FN_CC
235 #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
237 #define BOOST_MEM_FN_NAME(X) X##_fastcall
238 #define BOOST_MEM_FN_CC __fastcall
240 #include <boost/bind/mem_fn_cc.hpp>
242 #undef BOOST_MEM_FN_NAME
243 #undef BOOST_MEM_FN_CC
247 // data member support
252 template<class R, class T> class dm
256 typedef R const & result_type;
257 typedef T const * argument_type;
264 template<class U> R const & call(U & u, T const *) const
269 template<class U> R & call(U & u, T *) const
274 template<class U> R const & call(U & u, void const *) const
276 return (get_pointer(u)->*f_);
281 explicit dm(F f): f_(f) {}
283 R & operator()(T * p) const
288 R const & operator()(T const * p) const
293 template<class U> R const & operator()(U & u) const
298 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) && !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
300 R & operator()(T & t) const
307 R const & operator()(T const & t) const
315 template<class R, class T> _mfi::dm<R, T> mem_fn(R T::*f)
317 return _mfi::dm<R, T>(f);
322 #endif // #ifndef BOOST_MEM_FN_HPP_INCLUDED