As mentioned earlier, the STL algorithm library has quite a verbose syntax, where every algorithm requires a pair of iterators as parameters. The ranges library has overloaded these functions but by taking a range as a parameter instead of a pair of iterators:
STL algorithms operates on iterators | Ranges library operates on containers |
std::sort(a.begin(), a.end()); std::count(a.begin(), a.end(), 12); | ranges::sort(a); ranges::count(a, 12); |
This makes the syntax of algorithms neater, but the main feature with the ranges library is the introduction of views.
Views in the range library are lazily evaluated iterations over a range. Technically they are only iterators with built in logic, but syntactically, ...