Replace boilerplate for deciding iterator_category of a view adaptor's iterator
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
Several iterator types for view adaptors have wording like this (from [range.filter.iterator]):
iterator::iterator_categoryis defined as follows:
- Let
Cdenote the typeiterator_traits<iterator_t<V>>::iterator_category. - If
Cmodelsderived_from<bidirectional_iterator_tag>, theniterator_categorydenotesbidirectional_iterator_tag. - Otherwise, if
Cmodelsderived_from<forward_iterator_tag>, theniterator_categorydenotesforward_iterator_tag. - Otherwise,
iterator_categorydenotesC.
We could avoid the repetition with an exposition-only helper along the lines of:
template<class C, class... Cats>
struct floor-cat
{ using type = C; };
template<class C, class Cat, class... Cats>
struct floor-cat
: conditional<derived_from<C, Cat>, Cat, floor-cat<C, Cats...>>
{ };
template<class T, class... Cats>
using floor-cat-t = typename floor-cat<T, Cats...>::type;
And then define iterator::iterator_category for the example above as floor-cat<iterator_traits<iterator_t<V>>::iterator_category, bidirectional_iterator_tag, forward_iterator_tag>.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by searching the draft for view-adaptor iterator definitions that repeat the iterator_category decision wording, including [range.filter.iterator]. Compare the affected clauses with the proposed floor-cat helper, then update the applicable wording consistently; done means the repeated boilerplate is replaced without changing the specified category behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100