June 2025
Intermediate to advanced
1093 pages
33h 24m
English
If you want to write your own range adapters for use in operator| chains, you need two things: an adapter class that implements your operation, and an instance of it, which is then the adapter itself. This is used to create closure objects. These objects are then instances where your adapter is “bound” to a specific range.
So you write a class MyAdp with operator() and then create an instance myAdp of it. If you now have a range rng, then myAdp(rng) is a range adapter closure object (or just a closure for short). The alternative way to create such a closure is to write rng | myAdp. You can then chain this closure with other operator| and ranges.
// https://godbolt.org/z/e54xzT9dW#include <ranges> ...
Read now
Unlock full access