sentinel_iterator.h 604 B

123456789101112131415161718192021222324252627
  1. //
  2. // sentinel_iterator.h
  3. // iterator
  4. //
  5. // Created by Sam Jaffe on 3/30/23.
  6. // Copyright © 2023 Sam Jaffe. All rights reserved.
  7. //
  8. #pragma once
  9. #include <iterator/forwards.h>
  10. #include <iterator/proxy.h>
  11. namespace iterator {
  12. template <typename It, typename S>
  13. class sentinel_iterator : public proxy<It, sentinel_iterator<It, S>> {
  14. public:
  15. using super_t = proxy<It, sentinel_iterator<It>>;
  16. using sentinel_type = sentinel_iterator;
  17. public:
  18. using super_t::super_t;
  19. bool at_end() const { return super_t::impl() == S(); }
  20. };
  21. }
  22. MAKE_ITERATOR_FACADE_TYPEDEFS_T(::iterator::sentinel_iterator);