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 standard-library algorithm calls when sorting collections such as students.
- How deep it goes
- Explains direct range passing and readability benefits, but stops short of surveying the API or its implementation.
- Examples
- Uses student sorting by GPA as the concrete ranges example.
- What you can do after
- Apply it via the C++ standard library by supplying a container and comparison function instead of iterator pairs.
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 sequence or data source through a traversal protocol.
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.

