skip_seq.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef BOOST_METAPARSE_V1_CPP98_IMPL_SKIP_SEQ_HPP
  2. #define BOOST_METAPARSE_V1_CPP98_IMPL_SKIP_SEQ_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/is_error.hpp>
  8. #include <boost/metaparse/v1/accept.hpp>
  9. #include <boost/metaparse/v1/get_remaining.hpp>
  10. #include <boost/metaparse/v1/get_position.hpp>
  11. #include <boost/metaparse/v1/get_result.hpp>
  12. namespace boost
  13. {
  14. namespace metaparse
  15. {
  16. namespace v1
  17. {
  18. namespace impl
  19. {
  20. struct skip_seq
  21. {
  22. private:
  23. template <class ParsingResult, class NewResultValue>
  24. struct change_result :
  25. accept<
  26. NewResultValue,
  27. typename get_remaining<ParsingResult>::type,
  28. typename get_position<ParsingResult>::type
  29. >
  30. {};
  31. template <class Result, class P>
  32. struct apply_unchecked :
  33. boost::mpl::eval_if<
  34. typename is_error<
  35. typename P::template apply<
  36. typename get_remaining<Result>::type,
  37. typename get_position<Result>::type
  38. >
  39. >::type,
  40. typename P::template apply<
  41. typename get_remaining<Result>::type,
  42. typename get_position<Result>::type
  43. >,
  44. change_result<
  45. typename P::template apply<
  46. typename get_remaining<Result>::type,
  47. typename get_position<Result>::type
  48. >,
  49. typename get_result<Result>::type
  50. >
  51. >
  52. {};
  53. public:
  54. template <class Result, class P>
  55. struct apply :
  56. boost::mpl::eval_if<
  57. is_error<Result>,
  58. Result,
  59. apply_unchecked<Result, P>
  60. >
  61. {};
  62. };
  63. }
  64. }
  65. }
  66. }
  67. #endif