std::ranges::contiguous_range(3cxx)
π std::ranges::contiguous_range β the libstdc++ glow-up, manual section 3cxx β¨
okay bestie, pull up a chair because we're about to talk about one of the most lowkey iconic concepts in <ranges>. it's std::ranges::contiguous_range, it lives in the libstdc++ manual (section 3cxx), and it's literally just out here being the range that knows its own memory is laid out all in a row. no cap.
πΈ NAME πΈ
std::ranges::contiguous_range β a range for which ranges::begin returns a contiguous iterator. that's it, that's the whole personality. π
β¨ SYNOPSIS β¨
she's a concept, so you don't call her, you satisfy her. first, the include:
#include <ranges>
π¦ Concept definition π¦
here's the exact definition, character for character, because we do not play with the source code:
template<typename _Tp>
concept std::ranges::contiguous_range = random_access_range<_Tp> && contiguous_iterator<iterator_t<_Tp>>
&& requires(_Tp& __t)
{
{ ranges::data(__t) } -> same_as<add_pointer_t<range_reference_t<_Tp>>>;
}
likeβ¦ look at her. three little requirements, all vibes, all correct. π
π Detailed Description π
a range for which ranges::begin returns a contiguous iterator.
that's the tea, that's the whole thing. if ranges::begin hands you back a contiguous iterator, congrats, your range is a contiguous_range. the elements are sitting right next to each other in memory like besties in a group photo. πΈβ¨
ok but real talk β this is a concept, so it's a compile-time vibe check, not a runtime thing. if it doesn't hold, your code doesn't compile. no takebacks. π
π Author π
generated automatically by Doxygen for libstdc++ from the source code. so like, no human wrote this one, it's giving main character energy from a documentation generator. iconic honestly. π€π
and that's the page, bestie! π«Ά source and version: libstdc++, manual section 3cxx, as the footer of this page says β so if you ever forget where you read this, it was libstdc++ the whole time. slay, go satisfy some concepts, and remember: contiguous memory is a love language. ππβ¨
π¦ where this page comes from
- ubuntu resolute: libstdc++-13-doc 13.4.0-10ubuntu1
- ubuntu resolute: libstdc++-16-doc 16-20260322-1ubuntu1
- ubuntu stonking: libstdc++-13-doc 13.5.0-1ubuntu1
- ubuntu stonking: libstdc++-16-doc 16.2.0-3ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms