function.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #ifndef PHOENIX_FUNCTION_FUNCTION_HPP
  7. #define PHOENIX_FUNCTION_FUNCTION_HPP
  8. #include <boost/spirit/home/phoenix/core/compose.hpp>
  9. #include <boost/spirit/home/phoenix/core/detail/function_eval.hpp>
  10. namespace boost { namespace phoenix
  11. {
  12. template <typename F>
  13. struct function
  14. {
  15. function() : f() {}
  16. function(F const& f_) : f(f_) {}
  17. actor<typename as_composite<detail::function_eval<0>, F>::type>
  18. operator()() const
  19. {
  20. return compose<detail::function_eval<0> >(f);
  21. }
  22. template <typename A0>
  23. actor<typename as_composite<detail::function_eval<1>, F, A0>::type>
  24. operator()(A0 const& _0) const
  25. {
  26. return compose<detail::function_eval<1> >(f, _0);
  27. }
  28. template <typename A0, typename A1>
  29. actor<typename as_composite<detail::function_eval<2>, F, A0, A1>::type>
  30. operator()(A0 const& _0, A1 const& _1) const
  31. {
  32. return compose<detail::function_eval<2> >(f, _0, _1);
  33. }
  34. // Bring in the rest of the function call operators
  35. #include <boost/spirit/home/phoenix/function/detail/function_call.hpp>
  36. F f;
  37. };
  38. }}
  39. #endif