8.9 KiB
[range.refinements]
25 Ranges library [ranges]
25.4 Range requirements [range.req]
25.4.6 Other range refinements [range.refinements]
The output_range concept specifies requirements of arange type for which ranges::begin returns a model of output_iterator ([iterator.concept.output]).
input_range, forward_range, bidirectional_range, and random_access_range are defined similarly.
`template<class R, class T> concept output_range = range && output_iterator<iterator_t, T>;
template concept input_range = range && input_iterator<iterator_t>;
template concept forward_range = input_range && forward_iterator<iterator_t>;
template concept bidirectional_range = forward_range && bidirectional_iterator<iterator_t>;
template concept random_access_range = bidirectional_range && random_access_iterator<iterator_t>; `
contiguous_range additionally requires that the ranges::data customization point object ([range.prim.data]) is usable with the range.
template<class T> concept [contiguous_range](#concept:contiguous_range "25.4.6 Other range refinements [range.refinements]") = [random_access_range](#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<T> && [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_iterator [iterator.concept.contiguous]")<iterator_t<T>> && requires(T& t) { { ranges::data(t) } -> [same_as](concept.same#concept:same_as "18.4.2 Concept same_as [concept.same]")<add_pointer_t<range_reference_t<T>>>; };
Given an expression t such that decltype((t)) is T&,T models contiguous_range only ifto_address(ranges::begin(t)) == ranges::data(t) is true.
The common_range concept specifies requirements of a range type for which ranges::begin andranges::end return objects of the same type.
[Example 1:
The standard containers ([containers]) model common_range.
â end example]
template<class T> concept [common_range](#concept:common_range "25.4.6 Other range refinements [range.refinements]") = [range](range.range#concept:range "25.4.2 Ranges [range.range]")<T> && [same_as](concept.same#concept:same_as "18.4.2 Concept same_as [concept.same]")<iterator_t<T>, sentinel_t<T>>;
template<class R> constexpr bool is-initializer-list = see below; // exposition only
For a type R,is-initializer-list is true if and only ifremove_cvref_t is a specialization of initializer_list.
The viewable_range concept specifies the requirements of arange type that can be converted to a view safely.
template<class T> concept [viewable_range](#concept:viewable_range "25.4.6 Other range refinements [range.refinements]") = [range](range.range#concept:range "25.4.2 Ranges [range.range]")<T> && (([view](range.view#concept:view "25.4.5 Views [range.view]")<remove_cvref_t<T>> && [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_from [concept.constructible]")<remove_cvref_t<T>, T>) || (<remove_cvref_t<T>> && (is_lvalue_reference_v<T> || ([movable](concepts.object#concept:movable "18.6 Object concepts [concepts.object]")<remove_reference_t<T>> && !is-initializer-list<T>))));
The constant_range concept specifies the requirements of arange type whose elements are not modifiable.
template<class T> concept [constant_range](#concept:constant_range "25.4.6 Other range refinements [range.refinements]") = [input_range](#concept:input_range "25.4.6 Other range refinements [range.refinements]")<T> && [constant-iterator](const.iterators.alias#concept:constant-iterator "24.5.3.2 Alias templates [const.iterators.alias]")<iterator_t<T>>;
The exposition-only concept sized-random-access-range specifies the requirements of a range type that is sized and allows random access to its elements.
template<class T> concept [sized-random-access-range](#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") = // exposition only [random_access_range](#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<R> && [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<R>;
[Note 1:
This concept constrains some parallel algorithm overloads; see [algorithms].
â end note]