adapt_callable.hpp 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*==============================================================================
  2. Copyright (c) 2005-2010 Joel de Guzman
  3. Copyright (c) 2011 Thomas Heller
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #ifndef BOOST_PHOENIX_FUNCTION_ADAPT_CALLABLE_HPP
  8. #define BOOST_PHOENIX_FUNCTION_ADAPT_CALLABLE_HPP
  9. #include <boost/phoenix/core/limits.hpp>
  10. #include <boost/phoenix/core/detail/function_eval.hpp>
  11. #include <boost/preprocessor/repetition/repeat.hpp>
  12. #define BOOST_PHOENIX_ADAPT_CALLABLE_NULLARY(NAME, FUNC) \
  13. boost::phoenix::detail::expression::function_eval<FUNC>::type const \
  14. inline NAME() \
  15. { \
  16. return boost::phoenix::detail::expression:: \
  17. function_eval<FUNC>::make(FUNC()); \
  18. } \
  19. /**/
  20. #define BOOST_PHOENIX_ADAPT_CALLABLE(NAME, FUNC, N) \
  21. template <BOOST_PHOENIX_typename_A(N)> \
  22. typename \
  23. boost::phoenix::detail::expression::function_eval< \
  24. FUNC \
  25. , BOOST_PHOENIX_A(N)>::type const \
  26. inline NAME(BOOST_PHOENIX_A_const_ref_a(N)) \
  27. { \
  28. return boost::phoenix::detail::expression:: \
  29. function_eval<FUNC, BOOST_PHOENIX_A(N)>:: \
  30. make(FUNC(), BOOST_PHOENIX_a(N)); \
  31. } \
  32. /**/
  33. #define BOOST_PHOENIX_ADAPT_CALLABLE_VARARG(NAME, FUNC) \
  34. BOOST_PHOENIX_ADAPT_CALLABLE_NULLARY(NAME, FUNC) \
  35. BOOST_PP_REPEAT_FROM_TO( \
  36. 1 \
  37. , BOOST_PHOENIX_LIMIT \
  38. , BOOST_PHOENIX_ADAPT_CALLABLE_VARARG_R \
  39. , (NAME, FUNC) \
  40. ) \
  41. /**/
  42. #define BOOST_PHOENIX_ADAPT_CALLABLE_VARARG_R(Z, N, D) \
  43. BOOST_PHOENIX_ADAPT_CALLABLE( \
  44. BOOST_PP_TUPLE_ELEM(2, 0, D) \
  45. , BOOST_PP_TUPLE_ELEM(2, 1, D) \
  46. , N \
  47. ) \
  48. /**/
  49. #endif