C++ Logo


Advanced search

[std-proposals] basic_string_view::const_reverse_iterator

From: Robert Allan Schwartz <notbob_at_[hidden]>
Date: Wed, 18 Jan 2023 16:54:10 +0000

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 {
// 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.

Thank you,

Robert Schwartz

Received on 2023-01-18 16:54:16