foldl_start_with_parser.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef BOOST_METAPARSE_V1_FOLDL_START_WITH_PARSER_HPP
  2. #define BOOST_METAPARSE_V1_FOLDL_START_WITH_PARSER_HPP
  3. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2012.
  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/foldl.hpp>
  8. namespace boost
  9. {
  10. namespace metaparse
  11. {
  12. namespace v1
  13. {
  14. template <class P, class StateP, class ForwardOp>
  15. class foldl_start_with_parser
  16. {
  17. private:
  18. template <class Res>
  19. struct apply_unchecked :
  20. foldl<P, typename get_result<Res>::type, ForwardOp>::template apply<
  21. typename get_remaining<Res>::type,
  22. typename get_position<Res>::type
  23. >
  24. {};
  25. public:
  26. typedef foldl_start_with_parser type;
  27. template <class S, class Pos>
  28. struct apply :
  29. boost::mpl::eval_if<
  30. typename is_error<typename StateP::template apply<S, Pos> >::type,
  31. typename StateP::template apply<S, Pos>,
  32. apply_unchecked<typename StateP::template apply<S, Pos> >
  33. >
  34. {};
  35. };
  36. }
  37. }
  38. }
  39. #endif