std::ranges::common_range(3)
π NAME π
std::ranges::common_range β okay bestie, this is literally the std::ranges::common_range concept, and the manual page is std::ranges::common_range(3) from the C++ Standard Library. thatβs the whole name vibe, periodt. π
β¨ Synopsis β¨
Defined in header <ranges>.
template< class T >
concept common_range =
(since C++20)
ranges::range<T> && std::same_as<ranges::iterator_t<T>,
ranges::sentinel_t<T>>;
The common_range concept is a refinement of range for which std::ranges::begin() and std::ranges::end() return the same type (e.g. all standard library containers). no cap, thatβs the whole point: begin and end are giving same-type energy. β¨
πΈ Example πΈ
run this code, bestie π«Ά:
// Run this code
#include <ranges>
struct A {
char* begin();
char* end();
};
static_assert( std::ranges::common_range<A> );
struct B {
char* begin();
bool end();
}; // not a common_range: begin/end have different types
static_assert( not std::ranges::common_range<B> );
struct C {
char* begin();
}; // not a common_range, not even a range: has no end()
static_assert( not std::ranges::common_range<C> );
int main() { }
π See also π
ranges::common_viewconverts a view into acommon_rangeviews::commonβ(class template)(range adaptor object)(C++20)
mwah π source/version: cppreference.com Β· date: 2024.06.10 Β· page: std::ranges::common_range(3) β byeee, go be iconic with your ranges ππ«Ά
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms