Namespaces
Variants
Views
Actions

std::ranges::range

From cppreference.com
< cpp‎ | ranges
 
 
 
Defined in header <ranges>
template< class T >

concept range = requires(T& t) {
  ranges::begin(t); // equality-preserving for forward iterators
  ranges::end  (t);

};

The range concept defines the requirements of a type that allows iteration over its elements by providing an iterator and sentinel that denote the elements of the range.

[edit] Semantic requirements

Given an expression E such that decltype((E)) is T, T models range only if

  • [ranges::begin(E), ranges::end(E)) denotes a range, and
  • both ranges::begin(E) and ranges::end(E) are amortized constant time and non-modifying, and
  • if the type of ranges::begin(E) models forward_iterator, ranges::begin(E) is equality-preserving (in other words, forward iterators support multi-pass algorithms)

Note: In the definition above, the required expressions ranges::begin(std::forward<T>(t)) and ranges::end(std::forward<T>(t)) do not require implicit expression variations.