std::ranges::common_range
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Ranges library
(C++23)(C++23)
(C++26)(C++26)
(C++23)(C++23)
(C++26)(C++26)
(C++26)(C++26)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
Defined in header
<ranges>
template< class T >
(since C++20)
concept common_range =
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).
[edit] Example
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() {}