Ranges are an abstraction that allow a C++ program
to operate on elements of data structures uniformly
. 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
.The
range concept requires that
ranges::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
with constant-time destruction and move operations
.Several refinements of
range group requirements
that arise frequently in concepts and algorithms
. Common ranges are ranges for which
ranges::begin and
ranges::end
return objects of the same type
. (Contiguous, bidirectional, forward, input, and output ranges
are defined similarly
.)
Viewable ranges can be converted to views
.