4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // NEVER INCLUDE DIRECTLY !! INCLUDE senf/membind.hh
25 #if !BOOST_PP_IS_ITERATING
27 #include <boost/preprocessor/cat.hpp>
28 #include <boost/preprocessor/repetition/enum_shifted.hpp>
29 #include <boost/preprocessor/iteration/iterate.hpp>
31 template <typename R, typename T1, typename T2>
32 boost::function<R()> membind(R (T1::* fn)(),T2 scOBTYPE ob)
34 return boost::bind(fn,static_cast<T1 scOBTYPE>(ob));
37 template <typename R, typename T1, typename T2>
38 boost::function<R()> membind(R (T1::* fn)() const, T2 const scOBTYPE ob)
40 return boost::bind(fn,static_cast<T1 const scOBTYPE>(ob));
43 template <typename R, typename T1, typename T2>
44 boost::function<R()> membind(R (T1::* fn)() const, T2 scOBTYPE ob)
46 return boost::bind(fn,static_cast<T1 const scOBTYPE>(ob));
49 // for BOOST_PP_ITERATION() in 2..9 do
50 #define BOOST_PP_ITERATION_PARAMS_1 (4, (2, 9, SENF_ABSOLUTE_INCLUDE_PATH(Utils/impl/membind.hh), 1))
51 #include BOOST_PP_ITERATE()
52 #elif BOOST_PP_ITERATION_DEPTH()==1 && BOOST_PP_ITERATION_FLAGS()==1
55 #define scARG(z,n,d) BOOST_PP_CAT(d,n)
56 #define scPARAMS(d) BOOST_PP_ENUM_SHIFTED(BOOST_PP_ITERATION(),scARG,d)
58 template < typename R, typename T1, typename T2, scPARAMS(typename A) >
59 boost::function<R ( scPARAMS(A) )>
60 membind(R (T1::* fn)( scPARAMS(A) ), T2 scOBTYPE ob)
62 return boost::bind(fn, static_cast<T1 scOBTYPE>(ob), scPARAMS(_) );
65 template < typename R, typename T1, typename T2, scPARAMS(typename A) >
66 boost::function<R ( scPARAMS(A) )>
67 membind(R (T1::* fn)( scPARAMS(A) ) const, T2 const scOBTYPE ob)
69 return boost::bind(fn, static_cast<T1 const scOBTYPE>(ob), scPARAMS(_) );
72 template < typename R, typename T1, typename T2, scPARAMS(typename A) >
73 boost::function<R ( scPARAMS(A) )>
74 membind(R (T1::* fn)( scPARAMS(A) ) const, T2 scOBTYPE ob)
76 return boost::bind(fn, static_cast<T1 const scOBTYPE>(ob), scPARAMS(_) );
90 // c-file-style: "senf"
91 // indent-tabs-mode: nil
92 // ispell-local-dictionary: "american"
93 // compile-command: "scons -u test"