foldl_reject_incomplete_start_with_parser.hpp 1.6 KB

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