14
Ranges
The strongest arguments prove nothing so long as the conclusions are not verified by experience.
– Roger Bacon
14.1 Introduction
The standard-library offers algorithms both constrained using concepts (Chapter 8) and unconstrained (for compatibility). The constrained (concept) versions are in <ranges> in namespace ranges. Naurally, I prefer the versions using concepts. A range is a generalization of the C++98 sequences defined by {begin(),end()} pairs; it specifies what it takes to be a sequence of elements. A range can be defined by
A {begin,end} pair of iterators
A {begin,n} pair, where begin is an iterator and n
Get A Tour of C++, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.