Title
begin and data must agree for contiguous_range
Status
c++20
Section
[range.refinements]
Submitter
Casey Carter

Created on 2020-01-25.00:00:00 last changed 45 months ago

Messages

Date: 2020-02-10.19:13:13

Proposed resolution:

This wording is relative to N4849.

  1. Modify [range.refinements] as indicated:

    -2- contiguous_range additionally requires that the ranges::data customization point ([range.prim.data]) is usable with the range.

    template<class T>
      concept contiguous_range =
        random_access_range<T> && contiguous_iterator<iterator_t<T>> &&
        requires(T& t) {
          { ranges::data(t) } -> same_as<add_pointer_t<range_reference_t<T>>>;
        };
    

    -?- Given an expression t such that decltype((t)) is T&, T models contiguous_range only if (to_address(ranges::begin(t)) == ranges::data(t)).

    -3- The common_range concept […]

Date: 2020-02-10.19:13:13

[ 2020-02 Prioritized as IMMEDIATE Monday morning in Prague ]

Date: 2020-01-26.21:13:32

The definition of the contiguous_range concept in [range.refinements]/2 requires that ranges::data(r) be valid for a contiguous_range r, but fails to impose the obvious semantic requirement that to_address(ranges::begin(r)) == ranges::data(r). In other words, data and begin must agree so that [begin(r), end(r)) and the counted range data(r) + [0, size(r)) (this is the new "counted range" specification syntax per working draft issue 2932) denote the same sequence of elements.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: immediate -> wp
2020-02-10 19:13:13adminsetmessages: + msg11016
2020-02-10 19:13:13adminsetstatus: new -> immediate
2020-01-25 15:35:46adminsetmessages: + msg10968
2020-01-25 00:00:00admincreate