visit_each.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*==============================================================================
  2. Copyright (c) 2005-2010 Joel de Guzman
  3. Copyright (c) 2010 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_VISIT_EACH_HPP
  8. #define BOOST_PHOENIX_CORE_VISIT_EACH_HPP
  9. #include <boost/phoenix/core/limits.hpp>
  10. #include <boost/fusion/algorithm/iteration/for_each.hpp>
  11. #include <boost/visit_each.hpp>
  12. namespace boost { namespace phoenix
  13. {
  14. template <typename> struct actor;
  15. namespace detail
  16. {
  17. template <typename Visitor>
  18. struct visit_each_impl
  19. {
  20. Visitor& visitor;
  21. visit_each_impl(Visitor& visitor_ ) : visitor(visitor_) {}
  22. template <typename T>
  23. void operator()(T const& t) const
  24. {
  25. using boost::visit_each;
  26. visit_each(visitor, t);
  27. }
  28. };
  29. }
  30. template <typename Visitor, typename Expr>
  31. inline void visit_each(Visitor& visitor, actor<Expr> const& a, long)
  32. {
  33. fusion::for_each(a, detail::visit_each_impl<Visitor>(visitor));
  34. }
  35. template <typename Visitor, typename Expr>
  36. inline void visit_each(Visitor& visitor, actor<Expr> const& a)
  37. {
  38. fusion::for_each(a, detail::visit_each_impl<Visitor>(visitor));
  39. }
  40. }}
  41. #endif