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

### 3381. `begin` and `data` must agree for `contiguous_range`

**Section:** 24.4.5 [range.refinements] **Status:** C++20
**Submitter:** Casey Carter **Opened:** 2020-01-25 **Last modified:** 2021-02-25

**Priority: **0

**View all other** issues in [range.refinements].

**View all issues with** C++20 status.

**Discussion:**

The definition of the `contiguous_range` concept in 24.4.5 [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.

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

**Proposed resolution:**

This wording is relative to N4849.

Modify 24.4.5 [range.refinements] as indicated:

-2- `contiguous_range` additionally requires that the `ranges::data` customization point
(24.3.13 [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 […]