base.hpp 919 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include "../end_aware_iterator.hpp"
  3. #include "traits.hpp"
  4. namespace iterator::recursive {
  5. /**
  6. * @class recursive_iterator_base
  7. * @brief A thin wrapper around end_aware_iterator for the purposes of
  8. * template metaprogramming.
  9. */
  10. template <typename Iterator>
  11. class base : public end_aware_iterator<Iterator> {
  12. public:
  13. using super = end_aware_iterator<Iterator>;
  14. protected:
  15. using recursive_category =
  16. std::conditional_t<is_associative<Iterator>{}, continue_layer_tag_t,
  17. terminal_layer_tag_t>;
  18. public:
  19. using super::super;
  20. base(super const & iter) : super(iter) {}
  21. base(super && iter) : super(std::move(iter)) {}
  22. protected:
  23. decltype(auto) get() const {
  24. if constexpr (is_associative<Iterator>{}) {
  25. return std::tie((**this).first, (**this).second);
  26. } else {
  27. return **this;
  28. }
  29. }
  30. };
  31. }