std::ranges::common_range - cppreference.com

From cppreference.com

template<classT>conceptcommon_range=ranges::range<T>&&std::same_as<ranges::iterator_t<T>,ranges::sentinel_t<T>>;(since C++20)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).

Example

Run this code

#include<ranges>structA{char*begin();char*end();};static_assert(std::ranges::common_range<A>);structB{char*begin();boolend();};// not a common_range: begin/end have different typesstatic_assert(notstd::ranges::common_range<B>);structC{char*begin();};// not a common_range, not even a range: has no end()static_assert(notstd::ranges::common_range<C>);intmain(){}See also