adapt_callable.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. inline \
  14. boost::phoenix::detail::expression::function_eval<FUNC>::type const \
  15. NAME() \
  16. { \
  17. return boost::phoenix::detail::expression:: \
  18. function_eval<FUNC>::make(FUNC()); \
  19. } \
  20. /**/
  21. #define BOOST_PHOENIX_ADAPT_CALLABLE(NAME, FUNC, N) \
  22. template <BOOST_PHOENIX_typename_A(N)> \
  23. inline \
  24. typename \
  25. boost::phoenix::detail::expression::function_eval< \
  26. FUNC \
  27. , BOOST_PHOENIX_A(N)>::type const \
  28. NAME(BOOST_PHOENIX_A_const_ref_a(N)) \
  29. { \
  30. return boost::phoenix::detail::expression:: \
  31. function_eval<FUNC, BOOST_PHOENIX_A(N)>:: \
  32. make(FUNC(), BOOST_PHOENIX_a(N)); \
  33. } \
  34. /**/
  35. #define BOOST_PHOENIX_ADAPT_CALLABLE_VARARG(NAME, FUNC) \
  36. BOOST_PHOENIX_ADAPT_CALLABLE_NULLARY(NAME, FUNC) \
  37. BOOST_PP_REPEAT_FROM_TO( \
  38. 1 \
  39. , BOOST_PHOENIX_LIMIT \
  40. , BOOST_PHOENIX_ADAPT_CALLABLE_VARARG_R \
  41. , (NAME, FUNC) \
  42. ) \
  43. /**/
  44. #define BOOST_PHOENIX_ADAPT_CALLABLE_VARARG_R(Z, N, D) \
  45. BOOST_PHOENIX_ADAPT_CALLABLE( \
  46. BOOST_PP_TUPLE_ELEM(2, 0, D) \
  47. , BOOST_PP_TUPLE_ELEM(2, 1, D) \
  48. , N \
  49. ) \
  50. /**/
  51. #endif