Ranges API
The C++ ranges API is a standard-library facility providing ranges, views, adaptors, and algorithms for processing sequences without explicit iterator pairs.
Learn C++ by Example
<ranges> is the C++ standard library header that declares ranges, views, and range adaptors.
- How it is used
- Uses views and adaptors to filter or transform containers while avoiding manual iterator tracking.
- How deep it goes
- Demonstrates drop_while, filter, pipe chaining, and validation, but does not develop adaptor internals.
- Examples
- Shows vector filtering, dropping values below three, checking nonnegative rows, and comparing iterator-based removal.
- What you can do after
- Apply it via std::views to compose readable filtering and skipping operations over containers.
100 C++ Mistakes and How to Avoid Them
The C++ ranges API is a standard-library interface for applying algorithms to ranges of elements without requiring explicit iterator pairs.
- How it is used
- Simplifies container processing by composing transformations and predicates without requiring explicit iterator pairs.
- How deep it goes
- Explains mapping, filtering, and reduction, and demonstrates a composed transform-and-filter pipeline.
- Examples
- Demonstrates transforming integers to absolute values, filtering evens, and accumulating their sum.
- What you can do after
- Apply C++ ranges and views to compose value transformations and filters before accumulation.
Read how 100 C++ Mistakes and How to Avoid Them explains ranges API →
Related concepts
- std::accumulatecontrasts with · std::accumulate is a C++ standard-library algorithm that combines the elements of a range into a result using an initial value and an accumulation operation.
- std::views::ziphas part · std::views::zip is a C++23 range adaptor that produces a view of tuples containing corresponding elements from multiple input ranges.
- iteratorcontrasts with · An iterator is an object or abstraction that provides successive values from a collection or other data source through a traversal interface.
- containeruses · A container is a logical or structural unit that holds, groups, or packages data or other elements as a single entity.
Questions about ranges API
What is ranges API?
The C++ ranges API is a standard-library facility providing ranges, views, adaptors, and algorithms for processing sequences without explicit iterator pairs.
Which Manning books explain ranges API?
Learn C++ by Example and 100 C++ Mistakes and How to Avoid Them.
What is the difference between ranges API and std::accumulate?
The C++ ranges API is a standard-library facility providing ranges, views, adaptors, and algorithms for processing sequences without explicit iterator pairs. std::accumulate is a C++ standard-library algorithm that combines the elements of a range into a result using an initial value and an accumulation operation.
What are the parts of ranges API?
Ranges API includes std::views::zip.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

