bind_member_function.hpp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*=============================================================================
  2. Copyright (c) 2001-2007 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #if !BOOST_PHOENIX_IS_ITERATING
  7. #ifndef PHOENIX_BIND_BIND_MEMBER_FUNCTION_HPP
  8. #define PHOENIX_BIND_BIND_MEMBER_FUNCTION_HPP
  9. #include <boost/phoenix/core/expression.hpp>
  10. #include <boost/phoenix/core/reference.hpp>
  11. #include <boost/phoenix/core/detail/function_eval.hpp>
  12. #include <boost/phoenix/bind/detail/member_function_ptr.hpp>
  13. namespace boost { namespace phoenix
  14. {
  15. template <typename RT, typename ClassT, typename ClassA>
  16. inline typename detail::expression::function_eval<
  17. detail::member_function_ptr<0, RT, RT(ClassT::*)()>
  18. , ClassA
  19. >::type const
  20. bind(RT(ClassT::*f)(), ClassA const& obj)
  21. {
  22. typedef detail::member_function_ptr<0, RT, RT(ClassT::*)()> fp_type;
  23. return
  24. detail::expression::function_eval<fp_type, ClassA>::make(
  25. fp_type(f)
  26. , obj
  27. );
  28. }
  29. template <typename RT, typename ClassT, typename ClassA>
  30. inline typename detail::expression::function_eval<
  31. detail::member_function_ptr<0, RT, RT(ClassT::*)() const>
  32. , ClassA
  33. >::type const
  34. bind(RT(ClassT::*f)() const, ClassA const& obj)
  35. {
  36. typedef
  37. detail::member_function_ptr<0, RT, RT(ClassT::*)() const>
  38. fp_type;
  39. return
  40. detail::expression::function_eval<fp_type, ClassA>::make(
  41. fp_type(f)
  42. , obj
  43. );
  44. }
  45. template <typename RT, typename ClassT>
  46. inline typename detail::expression::function_eval<
  47. detail::member_function_ptr<0, RT, RT(ClassT::*)()>
  48. , ClassT
  49. >::type const
  50. bind(RT(ClassT::*f)(), ClassT& obj)
  51. {
  52. typedef detail::member_function_ptr<0, RT, RT(ClassT::*)()> fp_type;
  53. return
  54. detail::expression::function_eval<
  55. fp_type
  56. , ClassT
  57. >::make(
  58. fp_type(f)
  59. , obj
  60. );
  61. }
  62. template <typename RT, typename ClassT>
  63. inline typename detail::expression::function_eval<
  64. detail::member_function_ptr<0, RT, RT(ClassT::*)() const>
  65. , ClassT
  66. >::type const
  67. bind(RT(ClassT::*f)() const, ClassT& obj)
  68. {
  69. typedef detail::member_function_ptr<0, RT, RT(ClassT::*)() const> fp_type;
  70. return
  71. detail::expression::function_eval<
  72. fp_type
  73. , ClassT
  74. >::make(
  75. fp_type(f)
  76. , obj
  77. );
  78. }
  79. #if !defined(BOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES)
  80. #include <boost/phoenix/bind/preprocessed/bind_member_function.hpp>
  81. #else
  82. #if defined(__WAVE__) && defined (BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  83. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/bind_member_function_" BOOST_PHOENIX_LIMIT_STR ".hpp")
  84. #endif
  85. /*=============================================================================
  86. Copyright (c) 2001-2007 Joel de Guzman
  87. Distributed under the Boost Software License, Version 1.0. (See accompanying
  88. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  89. ==============================================================================*/
  90. #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  91. #pragma wave option(preserve: 1)
  92. #endif
  93. #define BOOST_PHOENIX_ITERATION_PARAMS \
  94. (3, (1, BOOST_PP_DEC(BOOST_PHOENIX_ACTOR_LIMIT), \
  95. <boost/phoenix/bind/bind_member_function.hpp>))
  96. #include BOOST_PHOENIX_ITERATE()
  97. #if defined(__WAVE__) && defined (BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  98. #pragma wave option(output: null)
  99. #endif
  100. #endif
  101. }}
  102. #endif
  103. #else
  104. template <
  105. typename RT
  106. , typename ClassT
  107. , BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, typename T)
  108. , typename ClassA
  109. , BOOST_PHOENIX_typename_A
  110. >
  111. inline
  112. typename detail::expression::function_eval<
  113. detail::member_function_ptr<
  114. BOOST_PHOENIX_ITERATION
  115. , RT
  116. , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
  117. >
  118. , ClassA
  119. , BOOST_PHOENIX_A
  120. >::type const
  121. bind(
  122. RT(ClassT::*f)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
  123. , ClassA const & obj
  124. , BOOST_PHOENIX_A_const_ref_a
  125. )
  126. {
  127. typedef detail::member_function_ptr<
  128. BOOST_PHOENIX_ITERATION
  129. , RT
  130. , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
  131. > fp_type;
  132. return
  133. detail::expression::function_eval<
  134. fp_type
  135. , ClassA
  136. , BOOST_PHOENIX_A
  137. >::make(
  138. fp_type(f)
  139. , obj
  140. , BOOST_PHOENIX_a
  141. );
  142. }
  143. template <
  144. typename RT
  145. , typename ClassT
  146. , BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, typename T)
  147. , typename ClassA
  148. , BOOST_PHOENIX_typename_A
  149. >
  150. inline
  151. typename detail::expression::function_eval<
  152. detail::member_function_ptr<
  153. BOOST_PHOENIX_ITERATION
  154. , RT
  155. , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) const
  156. >
  157. , ClassA
  158. , BOOST_PHOENIX_A
  159. >::type const
  160. bind(
  161. RT(ClassT::*f)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) const
  162. , ClassA const & obj
  163. , BOOST_PHOENIX_A_const_ref_a
  164. )
  165. {
  166. typedef detail::member_function_ptr<
  167. BOOST_PHOENIX_ITERATION
  168. , RT
  169. , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) const
  170. > fp_type;
  171. return
  172. detail::expression::function_eval<
  173. fp_type
  174. , ClassA
  175. , BOOST_PHOENIX_A
  176. >::make(
  177. fp_type(f)
  178. , obj
  179. , BOOST_PHOENIX_a
  180. );
  181. }
  182. template <
  183. typename RT
  184. , typename ClassT
  185. , BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, typename T)
  186. , BOOST_PHOENIX_typename_A
  187. >
  188. inline
  189. typename detail::expression::function_eval<
  190. detail::member_function_ptr<
  191. BOOST_PHOENIX_ITERATION
  192. , RT
  193. , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
  194. >
  195. , ClassT
  196. , BOOST_PHOENIX_A
  197. >::type const
  198. bind(
  199. RT(ClassT::*f)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
  200. , ClassT & obj
  201. , BOOST_PHOENIX_A_const_ref_a
  202. )
  203. {
  204. typedef detail::member_function_ptr<
  205. BOOST_PHOENIX_ITERATION
  206. , RT
  207. , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
  208. > fp_type;
  209. return
  210. detail::expression::function_eval<
  211. fp_type
  212. , ClassT
  213. , BOOST_PHOENIX_A
  214. >::make(
  215. fp_type(f)
  216. , obj
  217. , BOOST_PHOENIX_a
  218. );
  219. }
  220. #endif