iterate_impl.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef BOOST_METAPARSE_V1_IMPL_ITERATE_IMPL_HPP
  2. #define BOOST_METAPARSE_V1_IMPL_ITERATE_IMPL_HPP
  3. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013.
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include <boost/metaparse/v1/impl/iterate_impl_unchecked.hpp>
  8. #include <boost/metaparse/v1/return_.hpp>
  9. #include <boost/metaparse/v1/is_error.hpp>
  10. #include <boost/mpl/eval_if.hpp>
  11. namespace boost
  12. {
  13. namespace metaparse
  14. {
  15. namespace v1
  16. {
  17. namespace impl
  18. {
  19. template <int N, class P, class Accum>
  20. struct iterate_impl
  21. {
  22. typedef iterate_impl type;
  23. template <class S, class Pos>
  24. struct apply :
  25. boost::mpl::eval_if<
  26. typename is_error<typename P::template apply<S, Pos> >::type,
  27. typename P::template apply<S, Pos>,
  28. iterate_impl_unchecked<N, P, Accum, S, Pos>
  29. >
  30. {};
  31. };
  32. template <class P, class Accum>
  33. struct iterate_impl<0, P, Accum> : return_<Accum> {};
  34. }
  35. }
  36. }
  37. }
  38. #endif