projecting_recursive_iterator.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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<It, detail::Projections<Projs...>, MaxDepth>
  12. : public RecursiveHelper<It, MaxDepth, detail::Projections<Projs...>>::type,
  13. public Facade<ProjectingRecursiveIterator<
  14. It, detail::Projections<Projs...>, MaxDepth>> {
  15. public:
  16. using sentinel_type = sentinel_t;
  17. public:
  18. ProjectingRecursiveIterator() = default;
  19. explicit ProjectingRecursiveIterator(Range auto & range, Projs... projs)
  20. : ProjectingRecursiveIterator(EndAwareIterator(range), projs...) {}
  21. explicit ProjectingRecursiveIterator(Range auto & range, MaxDepth,
  22. Projs... projs)
  23. : ProjectingRecursiveIterator(EndAwareIterator(range), projs...) {}
  24. explicit ProjectingRecursiveIterator(EndAwareIterator<It> iter, MaxDepth,
  25. Projs... projs)
  26. : ProjectingRecursiveIterator::RecursiveBase(iter, projs...) {}
  27. explicit ProjectingRecursiveIterator(EndAwareIterator<It> iter,
  28. Projs... projs)
  29. : ProjectingRecursiveIterator::RecursiveBase(iter, projs...) {}
  30. template <typename Ot>
  31. explicit ProjectingRecursiveIterator(EndAwareIterator<Ot> other,
  32. Projs... projs)
  33. : ProjectingRecursiveIterator(EndAwareIterator<It>(other), projs...) {}
  34. template <typename Ot>
  35. explicit ProjectingRecursiveIterator(EndAwareIterator<Ot> other, MaxDepth,
  36. Projs... projs)
  37. : ProjectingRecursiveIterator(EndAwareIterator<It>(other), projs...) {}
  38. };
  39. template <Range R, typename... Projs>
  40. ProjectingRecursiveIterator(R, Projs...)
  41. -> ProjectingRecursiveIterator<iterator_t<R>, detail::Projections<Projs...>,
  42. bounded<sizeof...(Projs) + 1>>;
  43. template <typename It, typename... Projs>
  44. ProjectingRecursiveIterator(EndAwareIterator<It>, Projs...)
  45. -> ProjectingRecursiveIterator<It, detail::Projections<Projs...>,
  46. bounded<sizeof...(Projs) + 1>>;
  47. template <Range R, typename... Projs, size_t N>
  48. requires(N > sizeof...(Projs))
  49. ProjectingRecursiveIterator(R, bounded<N>, Projs...)
  50. -> ProjectingRecursiveIterator<iterator_t<R>, detail::Projections<Projs...>,
  51. bounded<N>>;
  52. template <typename It, typename... Projs, size_t N>
  53. requires(N > sizeof...(Projs))
  54. ProjectingRecursiveIterator(EndAwareIterator<It>, bounded<N>, Projs...)
  55. -> ProjectingRecursiveIterator<It, detail::Projections<Projs...>,
  56. bounded<N>>;
  57. template <Range R, typename... Projs>
  58. ProjectingRecursiveIterator(R, unbounded, Projs...)
  59. -> ProjectingRecursiveIterator<iterator_t<R>, detail::Projections<Projs...>,
  60. unbounded>;
  61. template <typename It, typename... Projs>
  62. ProjectingRecursiveIterator(EndAwareIterator<It>, unbounded, Projs...)
  63. -> ProjectingRecursiveIterator<It, detail::Projections<Projs...>,
  64. unbounded>;
  65. }