cascade_iterator.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #pragma once
  2. #include <cstddef>
  3. #include <iterator/concepts.h>
  4. #include <iterator/detail/projection_tuple.h>
  5. #include <iterator/detail/recursive_expander.h>
  6. #include <iterator/end_aware_iterator.h>
  7. #include <iterator/forwards.h>
  8. #include <iterator/recursive_iterator.h>
  9. namespace iterator {
  10. template <typename It, typename Projs, typename MaxDepth>
  11. class ProjectingRecursiveIterator;
  12. template <typename It, typename... Projs, typename MaxDepth>
  13. class ProjectingRecursiveIterator<It, detail::Projections<Projs...>, MaxDepth>
  14. : public RecursiveHelper<It, MaxDepth, detail::Projections<Projs...>>::type,
  15. public Facade<ProjectingRecursiveIterator<
  16. It, detail::Projections<Projs...>, MaxDepth>> {
  17. public:
  18. using sentinel_type = sentinel_t;
  19. public:
  20. ProjectingRecursiveIterator() = default;
  21. explicit ProjectingRecursiveIterator(Range auto & range, Projs... projs)
  22. : ProjectingRecursiveIterator(EndAwareIterator(range), projs...) {}
  23. explicit ProjectingRecursiveIterator(Range auto & range, MaxDepth,
  24. Projs... projs)
  25. : ProjectingRecursiveIterator(EndAwareIterator(range), projs...) {}
  26. explicit ProjectingRecursiveIterator(EndAwareIterator<It> iter, MaxDepth,
  27. Projs... projs)
  28. : ProjectingRecursiveIterator::RecursiveBase(iter, projs...) {}
  29. explicit ProjectingRecursiveIterator(EndAwareIterator<It> iter,
  30. Projs... projs)
  31. : ProjectingRecursiveIterator::RecursiveBase(iter, projs...) {}
  32. template <typename Ot>
  33. explicit ProjectingRecursiveIterator(EndAwareIterator<Ot> other,
  34. Projs... projs)
  35. : ProjectingRecursiveIterator(EndAwareIterator<It>(other), projs...) {}
  36. template <typename Ot>
  37. explicit ProjectingRecursiveIterator(EndAwareIterator<Ot> other, MaxDepth,
  38. Projs... projs)
  39. : ProjectingRecursiveIterator(EndAwareIterator<It>(other), projs...) {}
  40. };
  41. template <Range R, typename... Projs>
  42. ProjectingRecursiveIterator(R, Projs...)
  43. -> ProjectingRecursiveIterator<iterator_t<R>, detail::Projections<Projs...>,
  44. bounded<sizeof...(Projs) + 1>>;
  45. template <typename It, typename... Projs>
  46. ProjectingRecursiveIterator(EndAwareIterator<It>, Projs...)
  47. -> ProjectingRecursiveIterator<It, detail::Projections<Projs...>,
  48. bounded<sizeof...(Projs) + 1>>;
  49. template <Range R, typename... Projs, size_t N>
  50. requires(N > sizeof...(Projs))
  51. ProjectingRecursiveIterator(R, bounded<N>, Projs...)
  52. -> ProjectingRecursiveIterator<iterator_t<R>, detail::Projections<Projs...>,
  53. bounded<N>>;
  54. template <typename It, typename... Projs, size_t N>
  55. requires(N > sizeof...(Projs))
  56. ProjectingRecursiveIterator(EndAwareIterator<It>, bounded<N>, Projs...)
  57. -> ProjectingRecursiveIterator<It, detail::Projections<Projs...>,
  58. bounded<N>>;
  59. template <Range R, typename... Projs>
  60. ProjectingRecursiveIterator(R, unbounded, Projs...)
  61. -> ProjectingRecursiveIterator<iterator_t<R>, detail::Projections<Projs...>,
  62. unbounded>;
  63. template <typename It, typename... Projs>
  64. ProjectingRecursiveIterator(EndAwareIterator<It>, unbounded, Projs...)
  65. -> ProjectingRecursiveIterator<It, detail::Projections<Projs...>,
  66. unbounded>;
  67. }