cplusplus / cplusplus/draft

using const_reverse_iterator = reverse_iterator<const_iterator>;

Open
#6,053 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

Hello,

Today I am making my first posts to this group. Please forgive me if I make mistakes. Thank you.

Here is the context:

Header <string_view>:

template<class charT, class traits = char_traits>
class basic_string_view {
public:
// types
using traits_type = traits;
using value_type = charT;
using pointer = value_type*;
using const_pointer = const value_type*;
using reference = value_type&;
using const_reference = const value_type&;
using const_iterator = implementation-defined ; // see 24.4.2.2
using iterator = const_iterator;228
using const_reverse_iterator = reverse_iterator<const_iterator>;
using reverse_iterator = const_reverse_iterator;

I understand that the alias declaration for const_reverse_iterator uses the only declaration of reverse_iterator that is in scope at that moment, which is std::reverse_iterator, but then reverse_iterator is defined again on the next line, which creates an ordering dependency. Wouldn't it be safer and clearer to say:

using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using reverse_iterator = const_reverse_iterator;

or even:

using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using reverse_iterator = std::reverse_iterator<const_iterator>;

as they end up being the same type anyway, and this would eliminate the ordering issue?

Thank you,

Robert Schwartz

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the <string_view> specification in the draft and reviewing the surrounding iterator type aliases. Check the C++ name-lookup and aliasing implications of the proposed qualification, then inspect the issue discussion for the intended resolution. Done means reaching a maintainable wording decision and updating the draft text if a change is accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.