4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 // NEVER INCLUDE DIRECTLY !! INCLUDE senf/membind.hh
31 #if !BOOST_PP_IS_ITERATING
33 #include <boost/preprocessor/cat.hpp>
34 #include <boost/preprocessor/repetition/enum_shifted.hpp>
35 #include <boost/preprocessor/iteration/iterate.hpp>
37 template <typename R, typename T1, typename T2>
38 boost::function<R()> membind(R (T1::* fn)(),T2 scOBTYPE ob)
40 return boost::bind(fn,static_cast<T1 scOBTYPE>(ob));
43 template <typename R, typename T1, typename T2>
44 boost::function<R()> membind(R (T1::* fn)() const, T2 const scOBTYPE ob)
46 return boost::bind(fn,static_cast<T1 const scOBTYPE>(ob));
49 template <typename R, typename T1, typename T2>
50 boost::function<R()> membind(R (T1::* fn)() const, T2 scOBTYPE ob)
52 return boost::bind(fn,static_cast<T1 const scOBTYPE>(ob));
55 // for BOOST_PP_ITERATION() in 2..9 do
56 #define BOOST_PP_ITERATION_PARAMS_1 (4, (2, 9, SENF_ABSOLUTE_INCLUDE_PATH(Utils/impl/membind.hh), 1))
57 #include BOOST_PP_ITERATE()
58 #elif BOOST_PP_ITERATION_DEPTH()==1 && BOOST_PP_ITERATION_FLAGS()==1
61 #define scARG(z,n,d) BOOST_PP_CAT(d,n)
62 #define scPARAMS(d) BOOST_PP_ENUM_SHIFTED(BOOST_PP_ITERATION(),scARG,d)
64 template < typename R, typename T1, typename T2, scPARAMS(typename A) >
65 boost::function<R ( scPARAMS(A) )>
66 membind(R (T1::* fn)( scPARAMS(A) ), T2 scOBTYPE ob)
68 return boost::bind(fn, static_cast<T1 scOBTYPE>(ob), scPARAMS(_) );
71 template < typename R, typename T1, typename T2, scPARAMS(typename A) >
72 boost::function<R ( scPARAMS(A) )>
73 membind(R (T1::* fn)( scPARAMS(A) ) const, T2 const scOBTYPE ob)
75 return boost::bind(fn, static_cast<T1 const scOBTYPE>(ob), scPARAMS(_) );
78 template < typename R, typename T1, typename T2, scPARAMS(typename A) >
79 boost::function<R ( scPARAMS(A) )>
80 membind(R (T1::* fn)( scPARAMS(A) ) const, T2 scOBTYPE ob)
82 return boost::bind(fn, static_cast<T1 const scOBTYPE>(ob), scPARAMS(_) );
96 // c-file-style: "senf"
97 // indent-tabs-mode: nil
98 // ispell-local-dictionary: "american"
99 // compile-command: "scons -u test"
100 // comment-column: 40