cpp-proposals-pub icon indicating copy to clipboard operation
cpp-proposals-pub copied to clipboard

P1684: Container requirement does not include .data() and pointer

Open mhoemmen opened this issue 3 years ago • 2 comments

P1684 currently constraints Container to be a contiguous container. This is insufficient, because a contiguous container does not require .data() or pointer. Instead, it requires iterator and const_iterator to be random access and contiguous iterators. The latter can be converted into a pointer, but not through .data().

mhoemmen avatar Jun 28 '22 21:06 mhoemmen

Suggested fix is to define access to the container's data via std::ranges::data. This avoids needing to require .data() separately.

mhoemmen avatar Jun 28 '22 22:06 mhoemmen

and pointer and data() is still fine in that case as members since std::ranges::data() produces a dereferencable thing.

crtrott avatar Jun 30 '22 16:06 crtrott