Title
Clarify span iterator and const_iterator behavior
Status
c++20
Section
[span.overview]
Submitter
Stephan T. Lavavej

Created on 2018-04-12.00:00:00 last changed 45 months ago

Messages

Date: 2018-06-12.01:05:16

Proposed resolution:

This wording is relative to N4741.

  1. Edit [span.overview] as indicated:

    -4- The iterator types for span is a random access iterator and a contiguous iteratorspan::iterator and span::const_iterator are random access iterators ([random.access.iterators]), contiguous iterators ([iterator.requirements.general]), and constexpr iterators ([iterator.requirements.general]). All requirements on container iterators ([container.requirements]) apply to span::iterator and span::const_iterator as well.

Date: 2018-06-12.01:05:16

[ 2018-06 Rapperswil: Adopted ]

Date: 2018-04-23.00:00:00

[ 2018-04-23 Moved to Tentatively Ready after 6 positive votes on c++std-lib. ]

Date: 2018-04-12.00:00:00

There are multiple issues with how span specifies its iterators:

  • const_iterator isn't mentioned.

  • The relationship between iterator and const_iterator isn't specified. (span isn't a container, so it doesn't receive this automatically.)

  • The iterators should be specified to be constexpr.

By imitating [string.view.iterators]/3 "All requirements on container iterators ([container.requirements]) apply to basic_string_view::const_iterator as well.", we can specify that iterator is convertible to const_iterator.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2018-06-12 01:05:16adminsetmessages: + msg9892
2018-06-12 01:05:16adminsetstatus: voting -> wp
2018-05-06 19:23:13adminsetstatus: ready -> voting
2018-05-05 12:09:50adminsetmessages: + msg9831
2018-05-05 12:09:50adminsetstatus: new -> ready
2018-04-22 14:59:16adminsetmessages: + msg9823
2018-04-12 00:00:00admincreate