Before fleshing out this idea, I wanted to float it here in order to get some remarks and comments.
From the cppreference (
http://en.cppreference.com/w/cpp/experimental), the proposal (
https://ericniebler.github.io/std/wg21/D4128.html), as well as Eric Niebler's talk (
https://www.youtube.com/watch?v=mFUXNMfaciE), I'm still not getting a clear understanding of how one might use these ranges for slicing of arrays with views. However, I believe ranges could later be used quite nicely for slicing, somewhat like
http://en.cppreference.com/w/cpp/numeric/valarray/slice, but far more powerful.
If a range view can be used as a parameter to a custom `operator[](...)`, this could be used for powerful custom operations on data arrays, much in the style of Python's slicing.
However, the syntax for such slicing is currently still annoying, where the best would look something like `vec[{0,5}]` and ranges would make this more powerful, but not prettier.
The suggestion:Introduce something a language feature around `:` (maybe only in conjunction with integers), possibly simply as a constructor for a range, so that e.g.
or with the `operator()(...)` enabling multi-dimensional slicing, quite like in python:
x(:,3) // instead of x(std::all, 3)
y(:,0:3) // instead of y(std::all, {0,3})
z(:5,:5)
Adding such Pythonesque syntax would, in my opinion, greatly ease the usage of arrays in context of numerical calculations. Since the new ranges feature is slowly coming together, it seems to me this could be a powerful addition to the language