Files
2025-10-25 03:02:53 +03:00

3.0 KiB
Raw Permalink Blame History

[range.req.general]

25 Ranges library [ranges]

25.4 Range requirements [range.req]

25.4.1 General [range.req.general]

1

#

Ranges are an abstraction that allows a C++ program to operate on elements of data structures uniformly.

Calling ranges::begin on a range returns an object whose type models input_or_output_iterator ([iterator.concept.iterator]).

Calling ranges::end on a range returns an object whose type S, together with the type I of the object returned by ranges::begin, models sentinel_for<S, I>.

The library formalizes the interfaces, semantics, and complexity of ranges to enable algorithms and range adaptors that work efficiently on different types of sequences.

2

#

The range concept requires thatranges::begin and ranges::end return an iterator and a sentinel, respectively.

The sized_range concept refines range with the requirement that ranges::size be amortized O(1).

The view concept specifies requirements on a range type to provide operations with predictable complexity.

3

#

Several refinements of range group requirements that arise frequently in concepts and algorithms.

Common ranges are ranges for whichranges::begin and ranges::end return objects of the same type.

Random access ranges are ranges for which ranges::begin returns a type that modelsrandom_access_iterator ([iterator.concept.random.access]).

(Contiguous, bidirectional, forward, input, and output ranges are defined similarly.)

Viewable ranges can be converted to views.