This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.

2826. string_view iterators use old wording

Section: 23.3.3.4 [string.view.iterators] Status: C++17 Submitter: Alisdair Meredith Opened: 2016-11-17 Last modified: 2017-07-30

Priority: 0

View all issues with C++17 status.

Discussion:

The wording for basic_string_view was written before the definition of a contiguous iterator was added to C++17 to avoid repeating redundant wording.

Suggested modification of 23.3.3.4 [string.view.iterators] p1 (stealing words from valarray begin/end):

-1- A constant random-access iterator type such that, for a const_iterator it, if &*(it + N) is valid, then &*(it + N) == (&*it) + NA type that meets the requirements of a constant random access iterator (24.2.7) and of a contiguous iterator (24.2.1) whose value_type is the template parameter charT.

[2017-01-27 Telecon]

Priority 0

Proposed resolution:

This wording is relative to N4606.

  1. Modify 23.3.3.4 [string.view.iterators] as indicated:

    using const_iterator = implementation-defined;
    

    -1- A constant random-access iterator type such that, for a const_iterator it, if &*(it + N) is valid, then &*(it + N) == (&*it) + Ntype that meets the requirements of a constant random access iterator (25.3.5.7 [random.access.iterators]) and of a contiguous iterator (25.3.1 [iterator.requirements.general]) whose value_type is the template parameter charT.

    -2- For a basic_string_view str, any operation that invalidates a pointer in the range [str.data(), str.data() + str.size()) invalidates pointers, iterators, and references returned from str's methods.

    -3- All requirements on container iterators (24.2 [container.requirements]) apply to basic_string_view::const_iterator as well.