nth_of_c_skip_remaining.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef BOOST_METAPARSE_V1_CPP11_IMPL_NTH_OF_C_SKIP_REMANING_HPP
  2. #define BOOST_METAPARSE_V1_CPP11_IMPL_NTH_OF_C_SKIP_REMANING_HPP
  3. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2017.
  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/get_remaining.hpp>
  9. #include <boost/metaparse/v1/get_position.hpp>
  10. #include <boost/metaparse/v1/return_.hpp>
  11. #include <type_traits>
  12. namespace boost
  13. {
  14. namespace metaparse
  15. {
  16. namespace v1
  17. {
  18. namespace impl
  19. {
  20. template <class FinalResult, class S, class Pos, class... Ps>
  21. struct nth_of_c_skip_remaining;
  22. template <class FinalResult, class S, class Pos>
  23. struct nth_of_c_skip_remaining<FinalResult, S, Pos> :
  24. return_<FinalResult>::template apply<S, Pos>
  25. {};
  26. template <class FinalResult, class S, class Pos, class P, class... Ps>
  27. struct nth_of_c_skip_remaining<FinalResult, S, Pos, P, Ps...>
  28. {
  29. private:
  30. template <class NextResult>
  31. struct apply_unchecked :
  32. nth_of_c_skip_remaining<
  33. FinalResult,
  34. typename get_remaining<NextResult>::type,
  35. typename get_position<NextResult>::type,
  36. Ps...
  37. >
  38. {};
  39. public:
  40. typedef
  41. typename std::conditional<
  42. is_error<typename P::template apply<S, Pos>>::type::value,
  43. typename P::template apply<S, Pos>,
  44. apply_unchecked<typename P::template apply<S, Pos>>
  45. >::type::type
  46. type;
  47. };
  48. }
  49. }
  50. }
  51. }
  52. #endif