| 1234567891011121314151617181920212223242526272829303132 |
- //
- // sentinel_iterator.h
- // iterator
- //
- // Created by Sam Jaffe on 3/30/23.
- // Copyright © 2023 Sam Jaffe. All rights reserved.
- //
- #pragma once
- #include <iterator/forwards.h>
- #include <iterator/proxy.h>
- namespace iterator {
- template <typename It, typename S>
- class sentinel_iterator : public proxy<It, sentinel_iterator<It, S>> {
- public:
- using super_t = proxy<It, sentinel_iterator<It, S>>;
- using sentinel_type = sentinel_iterator;
- public:
- using super_t::super_t;
- sentinel_iterator(S) : super_t() {}
- bool equal_to(sentinel_iterator const & other) const {
- return (at_end() && other.at_end()) || super_t::impl() == other.impl();
- }
- bool at_end() const { return super_t::impl() == S(); }
- };
- }
- MAKE_ITERATOR_FACADE_TYPEDEFS_T(::iterator::sentinel_iterator);
|