Range library for C++11/14/17. This code is the basis of a formal proposal to add range support to the C++ standard library.
Why does C++ need another range library? Simply put, the existing solutions haven’t kept up with the rapid evolution of C++. Range v3 is a library for the future C++. Not only does it work well with today’s C++ – move semantics, lambdas, automatically deduced types and all – it also anticipates tomorrow’s C++ with Concepts.
Range v3 forms the basis of a proposal to add range support to the standard library (N4128: Ranges for the Standard Library). It also will be the reference implementation for an upcoming Technical Specification. These are the first steps toward turning ranges into an international standard.
Check out the (woefully incomplete) documentation here.
Other resources (mind the dates, the library probably has changed since then):
Most of the source code in this project are mine, and those are under the Boost Software License. Parts are taken from Alex Stepanov’s Elements of Programming, Howard Hinnant’s libc++, and from the SGI STL. Please see the attached LICENSE file and the CREDITS file for the licensing and acknowledgments.
The code is known to work on the following compilers:
Development Status: This code is fairly stable, well-tested, and suitable for casual use, although currently lacking documentation. No promise is made about support or long-term stability. This code will evolve without regard to backwards compatibility.
view_interfacegets a bounds-checking
chunk_viewworks on Input ranges.
contiguous_iterator_tagiterator category tag.
action::insertavoids interfering with
vector’s exponentional growth strategy.
sharedview for views that need container-like scratch space to do their work.
ranges::reference_wrapperto avoid LWG#2993.
any_view, the type-erased view wrapper.
stride_viewno longer needs an
adjacent_filter_viewsupports bidirectional iteration.
view_adaptorcleanup to remove the need for a
mutabledata member holding the adapted view.
tail_viewof an empty range is an empty range, not undefined behavior.
any_views are now much more efficicient (from @CaseyCarter)
<thread>header (from @CaseyCarter)
ranges::optionalnow behaves like
view::chunkworks on Input ranges (from @CaseyCarter)
for_each_nalgorithm (from @khlebnikov)
vectorbroken on Clang 3.8.1 since ~last Xmas (ericniebler/range-v3#632).
view::linear_distribute(from,to,n)- A view of
to, distributed evenly.
view::indices(n)- A view of the indices
view::closed_indices(n)- A view of the indices
This release deprecates
view::ints(n) as confusing to new users.
Many interfaces are simply renamed. The following table shows the old names
and the new. (All names are in the
|Old Name||New Name|
common_iteratornow requires that its two types (
Sentinel) are different. Use
common_iterator_t<I, S>to get the old behavior (i.e., if the two types are the same, it is an alias for
I; otherwise, it is
(In practice, this has very little effect but it may effect overloading in rare situations.)
ranges::is_swappablenow only takes one template parameter. The new
ranges::is_swappable_with<T, U>tests whether
ranges::is_swappable<T>is equivalent to
ranges::is_swappable_with<T &, T &>.
Viewconcept is no longer satisfied by reference types.
Writableconcept to fix #537.
I do this work because I love it and because I love C++ and want it to be as excellent as I know it can be. If you like my work and are looking for a way to say thank you, you can leave a supportive comment on my blog. Or you could leave me some kudos on my Open Hub range-v3 contribution page. Just click the Give Kudos button here.