Commit 9507064
committed
Address iterator_category failing to compile for input iterators
The wording of P2727R4 states, with respect to the iterator_category
type alias:
"The nested type iterator_category is defined if and only if
IteratorConcept is derived from forward_iterator_tag."
Previously, this implementation had attempted to implement this using
a class template detail::iter_cat, which had a specialization that
contained an iterator_category member type alias which was only
enabled if IteratorConcept was derived from
std::forward_iterator_tag. However, the iter_category member type
alias of iterator_interface itself was specified as
detail::iter_cat</* ... */>>::iterator_category, which caused
iterator_interface to simply fail to compile if IteratorConcept was
not derived from forward_iterator_tag as detail::iter_cat's
iterator_category was not found.
This commit addresses the issue by removing the iterator_category
member type alias from iterator_interface itself and making
iterator_interface provide the member type alias by inheriting from
detail::iter_cat, which satisfies the requirement in the wording. It
also adds a reproducing unit test.1 parent fed466b commit 9507064
File tree
2 files changed
+34
-6
lines changed- include/beman/iterator_interface
- tests/beman/iterator_interface
2 files changed
+34
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
158 | | - | |
| 157 | + | |
159 | 158 | | |
160 | 159 | | |
161 | 160 | | |
162 | 161 | | |
163 | 162 | | |
164 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
165 | 166 | | |
166 | 167 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | 168 | | |
171 | 169 | | |
172 | 170 | | |
| |||
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
122 | 152 | | |
123 | 153 | | |
0 commit comments