std::ranges::contiguous_range - cppreference.com (original) (raw)
The contiguous_range
concept is a refinement of range for which ranges::begin returns a model of contiguous_iterator and the customization point ranges::data is usable.
[edit] Semantic requirements
T
models contiguous_range
only if given an expression e
such that decltype((e)) is T&, std::to_address(ranges::begin(e)) == ranges::data(e).
[edit] Example
#include #include #include #include #include #include #include #include #include #include template concept CR = std::ranges::contiguous_range; // zstring being a ranges::contiguous_range doesn't have to be a ranges::sized_range struct zstring { struct sentinel { friend constexpr bool operator==(const char* str, sentinel) noexcept { return str == '\0'; } }; const char str; const char* begin() const noexcept { return str; } sentinel end() const noexcept { return {}; } }; int main() { int a[4]; static_assert( CR<std::vector> and not CR<std::vector> and not CR<std::deque> and CR<std::valarray> and CR<decltype(a)> and not CR<std::list> and not CR<std::set> and CR<std::array<std::list,42>> and CR<std::string_view> and CR and CR<std::span> and not CR<std::mdspan<int, std::dims<1>>> ); }