call.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_CORE_CALL_HPP
  8. #define BOOST_PHOENIX_CORE_CALL_HPP
  9. #include <boost/phoenix/core/limits.hpp>
  10. #include <boost/phoenix/core/environment.hpp>
  11. #include <boost/proto/proto_fwd.hpp>
  12. #include <boost/proto/traits.hpp>
  13. #include <boost/proto/transform/impl.hpp>
  14. namespace boost { namespace phoenix
  15. {
  16. namespace detail
  17. {
  18. template <
  19. typename Fun
  20. , typename Expr
  21. , typename State
  22. , typename Data
  23. , long Arity = proto::arity_of<Expr>::value
  24. >
  25. struct call_impl;
  26. template <typename Fun, typename Expr, typename State, typename Data>
  27. struct call_impl<Fun, Expr, State, Data, 0>
  28. : proto::transform_impl<Expr, State, Data>
  29. {
  30. typedef
  31. typename boost::phoenix::result_of::context<State, Data>::type
  32. context_type;
  33. typedef
  34. typename boost::result_of<
  35. Fun(Expr, context_type)
  36. >::type
  37. result_type;
  38. result_type operator()(
  39. typename call_impl::expr_param e
  40. , typename call_impl::state_param s
  41. , typename call_impl::data_param d
  42. ) const
  43. {
  44. return Fun()(e, boost::phoenix::context(s, d));
  45. }
  46. };
  47. }
  48. template <typename Fun, typename Dummy = void>
  49. struct call
  50. : proto::transform<call<Fun> >
  51. {
  52. template <typename Expr, typename State, typename Data>
  53. struct impl
  54. : detail::call_impl<Fun, Expr, State, Data>
  55. {};
  56. };
  57. #include <boost/phoenix/core/detail/call.hpp>
  58. }
  59. namespace proto
  60. {
  61. template <typename Fun, typename Dummy>
  62. struct is_callable<phoenix::call<Fun, Dummy> > : mpl::true_ {};
  63. }
  64. }
  65. #endif