bind_function.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #include <boost/phoenix/core/expression.hpp>
  8. #include <boost/phoenix/core/detail/function_eval.hpp>
  9. #include <boost/phoenix/bind/detail/cpp03/function_ptr.hpp>
  10. namespace boost { namespace phoenix {
  11. template <
  12. typename RT
  13. >
  14. inline
  15. typename detail::expression::function_eval<
  16. detail::function_ptr<0, RT, RT(*)()>
  17. >::type const
  18. bind(RT(*f)())
  19. {
  20. typedef detail::function_ptr<0, RT, RT(*)()> fp_type;
  21. return detail::expression::function_eval<fp_type>::make(fp_type(f));
  22. }
  23. template <
  24. typename RT
  25. , typename T0
  26. , typename A0
  27. >
  28. inline
  29. typename detail::expression::function_eval<
  30. detail::function_ptr<1, RT, RT(*)(T0)>
  31. , A0
  32. >::type const
  33. bind(RT(*f)(T0), A0 const & a0)
  34. {
  35. typedef detail::function_ptr<1, RT, RT(*)(T0)> fp_type;
  36. return detail::expression::function_eval<fp_type, A0>::make(fp_type(f), a0);
  37. }
  38. #if !defined(BOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES)
  39. #include <boost/phoenix/bind/detail/cpp03/preprocessed/bind_function.hpp>
  40. #else
  41. #if defined(__WAVE__) && defined (BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  42. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/bind_function_" BOOST_PHOENIX_LIMIT_STR ".hpp")
  43. #endif
  44. /*=============================================================================
  45. Copyright (c) 2001-2007 Joel de Guzman
  46. Distributed under the Boost Software License, Version 1.0. (See accompanying
  47. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  48. ==============================================================================*/
  49. #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  50. #pragma wave option(preserve: 1)
  51. #endif
  52. #define BOOST_PHOENIX_ITERATION_PARAMS \
  53. (3, (2, BOOST_PP_DEC(BOOST_PHOENIX_ACTOR_LIMIT), \
  54. <boost/phoenix/bind/detail/cpp03/bind_function.hpp>))
  55. #include BOOST_PHOENIX_ITERATE()
  56. #if defined(__WAVE__) && defined (BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  57. #pragma wave option(output: null)
  58. #endif
  59. #endif
  60. }}
  61. #else
  62. template <
  63. typename RT
  64. , BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, typename T)
  65. , BOOST_PHOENIX_typename_A
  66. >
  67. inline
  68. typename detail::expression::function_eval<
  69. detail::function_ptr<
  70. BOOST_PHOENIX_ITERATION
  71. , RT
  72. , RT(*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
  73. >
  74. , BOOST_PHOENIX_A
  75. >::type const
  76. bind(
  77. RT(*f)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
  78. , BOOST_PHOENIX_A_const_ref_a
  79. )
  80. {
  81. typedef detail::function_ptr<
  82. BOOST_PHOENIX_ITERATION
  83. , RT
  84. , RT(*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
  85. > fp_type;
  86. return
  87. detail::expression::function_eval<
  88. fp_type
  89. , BOOST_PHOENIX_A
  90. >::make(
  91. fp_type(f)
  92. , BOOST_PHOENIX_a
  93. );
  94. }
  95. #endif