C++ Logo


Advanced search

Re: [std-proposals] basic_string_view::const_reverse_iterator

From: Robert Allan Schwartz <notbob_at_[hidden]>
Date: Wed, 18 Jan 2023 17:33:19 +0000
Hi Arthur,

Thanks for your kind reply!

I submitted this to the github for editorial changes. Jonathan Wakely replied: "Yes, we should use std::reverse_iterator here."

I don't know how to use github (other than how to sign up in order to make editorial posts), so any help you are willing to offer me is deeply appreciated.

Warm regards,


On Jan 18, 2023, at 12:27 PM, Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]> wrote:

Hi Robert,

This would be what we'd call an "editorial change" — one with no functional/behavioral change, just fiddling with the wording (hopefully for the better).

You've identified an inconsistency in style between
etc. etc.

I agree with you that this is worth fixing — not primarily because the wording in [string.view] is confusing to the reader (as Jason said, there's really only one interpretation that makes sense), but rather because the wording in [string.view] is inconsistent with the established practice in all those other sections. Deviations from the best practice ought to have a reason; and in this case I don't think there is a valid reason — it's just gratuitously inconsistent.

Editorial changes — unless unusually large, subtle, or controversial — are generally handled via pull requests, not papers.

So your next step would be to clone https://github.com/cplusplus/draft , grep for all instances of `using reverse_iterator =`, find all the inconsistent instances, make a commit that fixes them all at once, and then pull-request it (N.B.: humbly ;) and including a link to this discussion). I think that'd be a good idea, and I'm willing to help with it if you need help. Unless of course someone shows the reason why [string.view] is inconsistent — it's possible there is a reason and I'm just not seeing it.

N.B.: Pull requests are the appropriate venue for editorial (non-behavioral) changes. Pull requests are not an appropriate mechanism for feature requests or behavioral changes of any kind.


On Wed, Jan 18, 2023 at 12:08 PM Robert Allan Schwartz via Std-Proposals <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>> wrote:
Hi Jason,

You're correct, there is nothing that *needs* to be changed.

I was only proposing an improvement for purposes of clarity, and to prevent a potential error if a future edition of the Standard mistakenly reverses the order of those two lines.



> On Jan 18, 2023, at 12:03 PM, Jason McKesson via Std-Proposals <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>> wrote:
> On Wed, Jan 18, 2023 at 11:54 AM Robert Allan Schwartz via
> Std-Proposals <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>> wrote:
>> 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
>> 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>;
>> This would eliminate the ordering issue.
> There is no ordering issue. Because `basic_string_view` exists inside
> the `std` namespace, `reverse_iterator` will refer to the namespace
> declaration. There is nothing that needs to be changed.
> --
> Std-Proposals mailing list
> Std-Proposals_at_lists.isocpp.org<mailto:Std-Proposals_at_[hidden]>
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Std-Proposals mailing list

Received on 2023-01-18 17:33:24