I've just seen the first part of Herb Sutter's "Writing Good C++14... By Default" (https://www.youtube.com/watch?v=hEx5DNLWGgA) and i have a (possible stupid) question regarding array_view.
The presented case was sending an array_view instead of a pointer and length in order to avoid pointer arithmetic, but how can array_view handle a case like this:
int vec[10];
func(vec+2, 5); //start from the 2nd element and process 5 of them
Does array_view support this kind of stuff or i just got the use-case wrong?
With string_view
you can do this:
const char* str = "hello world!";
func(std::experimental::string_view(str + 2, 5));
That is use one of the constructors of the view to to build it from a substring.
So with array_view
you'll probably be able to do this:
int vec[10];
func(std::experimental::array_view(vec + 2, 5));
Note: There doesn't seem to be any official array_view
as of c++14.