11// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
22
3- #ifndef BEMAN_ANY_VIEW_DETAIL_ITERATOR_HPP
4- #define BEMAN_ANY_VIEW_DETAIL_ITERATOR_HPP
3+ #ifndef BEMAN_ANY_VIEW_DETAIL_ANY_ITERATOR_HPP
4+ #define BEMAN_ANY_VIEW_DETAIL_ANY_ITERATOR_HPP
55
66#include < beman/any_view/concepts.hpp>
77#include < beman/any_view/detail/intrusive_small_ptr.hpp>
1616namespace beman ::any_view::detail {
1717
1818template <class IterConceptT , class ElementT , class RefT , class RValueRefT , class DiffT >
19- class iterator {
19+ class any_iterator {
2020 using reference = RefT;
2121 using rvalue_reference = RValueRefT;
2222 using pointer = std::add_pointer_t <RefT>;
@@ -38,16 +38,9 @@ class iterator {
3838 intrusive_small_ptr<interface_type, 3 * sizeof (void *)> iterator_ptr;
3939
4040 template <class IteratorT , class SentinelT >
41- using adaptor_type = detail::iterator_adaptor<ElementT, reference, rvalue_reference, DiffT, IteratorT, SentinelT>;
42-
43- template <class IteratorT , class SentinelT >
44- static constexpr auto get_noexcept () {
45- return std::is_nothrow_constructible_v<adaptor_type<IteratorT, SentinelT>, IteratorT, SentinelT>;
46- }
47-
48- template <class IteratorT , class SentinelT >
49- static constexpr auto get_in_place_adaptor_type () {
50- return std::in_place_type<adaptor_type<IteratorT, SentinelT>>;
41+ static consteval auto get_in_place_adaptor_type () {
42+ return std::in_place_type<
43+ detail::iterator_adaptor<ElementT, reference, rvalue_reference, DiffT, IteratorT, SentinelT>>;
5144 }
5245
5346 public:
@@ -56,28 +49,28 @@ class iterator {
5649 using difference_type = DiffT;
5750
5851 template <detail::iterator_compatible_with<range_traits> IteratorT, std::sentinel_for<IteratorT> SentinelT>
59- constexpr iterator (IteratorT iterator, SentinelT sentinel) noexcept (get_noexcept<IteratorT, SentinelT>() )
52+ constexpr any_iterator (IteratorT iterator, SentinelT sentinel)
6053 : iterator_ptr(get_in_place_adaptor_type<IteratorT, SentinelT>(), std::move(iterator), std::move(sentinel)) {}
6154
62- constexpr iterator () noexcept
55+ constexpr any_iterator () noexcept
6356 requires forward
64- : iterator (pointer(nullptr ), pointer(nullptr )) {}
57+ : any_iterator (pointer(nullptr ), pointer(nullptr )) {}
6558
66- constexpr iterator (const iterator &)
59+ constexpr any_iterator (const any_iterator &)
6760 requires forward
6861 = default;
6962
70- constexpr iterator (iterator &&) noexcept = default;
63+ constexpr any_iterator (any_iterator &&) noexcept = default;
7164
72- constexpr auto operator =(const iterator &) -> iterator &
65+ constexpr auto operator =(const any_iterator &) -> any_iterator &
7366 requires forward
7467 = default ;
7568
76- constexpr auto operator =(iterator &&) noexcept -> iterator & = default ;
69+ constexpr auto operator =(any_iterator &&) noexcept -> any_iterator & = default ;
7770
7871 [[nodiscard]] constexpr auto operator *() const -> reference { return **iterator_ptr; }
7972
80- friend constexpr auto iter_move (const iterator & other) -> rvalue_reference {
73+ [[nodiscard]] friend constexpr auto iter_move (const any_iterator & other) -> rvalue_reference {
8174 return other.iterator_ptr ->iter_move ();
8275 }
8376
@@ -87,83 +80,83 @@ class iterator {
8780 return std::to_address (*iterator_ptr);
8881 }
8982
90- constexpr auto operator ++() -> iterator & {
83+ constexpr auto operator ++() -> any_iterator & {
9184 ++*iterator_ptr;
9285 return *this ;
9386 }
9487
9588 constexpr auto operator ++(int ) -> void { ++*this ; }
9689
97- [[nodiscard]] constexpr auto operator ++(int ) -> iterator
90+ [[nodiscard]] constexpr auto operator ++(int ) -> any_iterator
9891 requires forward
9992 {
10093 const auto other = *this ;
10194 ++*this ;
10295 return other;
10396 }
10497
105- [[nodiscard]] constexpr auto operator ==(const iterator & other) const -> bool
98+ [[nodiscard]] constexpr auto operator ==(const any_iterator & other) const -> bool
10699 requires forward
107100 {
108101 return *iterator_ptr == *other.iterator_ptr ;
109102 }
110103
111- constexpr auto operator --() -> iterator &
104+ constexpr auto operator --() -> any_iterator &
112105 requires bidirectional
113106 {
114107 --*iterator_ptr;
115108 return *this ;
116109 }
117110
118- [[nodiscard]] constexpr auto operator --(int ) -> iterator
111+ [[nodiscard]] constexpr auto operator --(int ) -> any_iterator
119112 requires bidirectional
120113 {
121114 const auto other = *this ;
122115 --*this ;
123116 return other;
124117 }
125118
126- [[nodiscard]] constexpr auto operator <=>(const iterator & other) const -> std::partial_ordering
119+ [[nodiscard]] constexpr auto operator <=>(const any_iterator & other) const -> std::partial_ordering
127120 requires random_access
128121 {
129122 return *iterator_ptr <=> *other.iterator_ptr ;
130123 }
131124
132- [[nodiscard]] constexpr auto operator -(const iterator & other) const -> difference_type
125+ [[nodiscard]] constexpr auto operator -(const any_iterator & other) const -> difference_type
133126 requires random_access
134127 {
135128 return *iterator_ptr - *other.iterator_ptr ;
136129 }
137130
138- constexpr auto operator +=(difference_type offset) -> iterator &
131+ constexpr auto operator +=(difference_type offset) -> any_iterator &
139132 requires random_access
140133 {
141134 *iterator_ptr += offset;
142135 return *this ;
143136 }
144137
145- [[nodiscard]] constexpr auto operator +(difference_type offset) const -> iterator
138+ [[nodiscard]] constexpr auto operator +(difference_type offset) const -> any_iterator
146139 requires random_access
147140 {
148141 auto other = *this ;
149142 other += offset;
150143 return other;
151144 }
152145
153- [[nodiscard]] friend constexpr auto operator +(difference_type offset, const iterator & other) -> iterator
146+ [[nodiscard]] friend constexpr auto operator +(difference_type offset, const any_iterator & other) -> any_iterator
154147 requires random_access
155148 {
156149 return other + offset;
157150 }
158151
159- constexpr auto operator -=(difference_type offset) -> iterator &
152+ constexpr auto operator -=(difference_type offset) -> any_iterator &
160153 requires random_access
161154 {
162155 *iterator_ptr -= offset;
163156 return *this ;
164157 }
165158
166- [[nodiscard]] constexpr auto operator -(difference_type offset) const -> iterator
159+ [[nodiscard]] constexpr auto operator -(difference_type offset) const -> any_iterator
167160 requires random_access
168161 {
169162 auto other = *this ;
@@ -184,4 +177,4 @@ class iterator {
184177
185178} // namespace beman::any_view::detail
186179
187- #endif // BEMAN_ANY_VIEW_DETAIL_ITERATOR_HPP
180+ #endif // BEMAN_ANY_VIEW_DETAIL_ANY_ITERATOR_HPP
0 commit comments