
6 Oct
2009
6 Oct
'09
11:07 a.m.
Neal Becker wrote:
OK, how about the attached?
In your attached example, int main () { double x[10]; for (int i = 0; i < 10; ++i) x[i] = i; double y = sum (make_array_range (x, 10)); std::cout << y << '\n'; } You could write instead of writing make_array_range(x, 10): - x (arrays are ranges) - as_array(x) (as_array is a no-op here, this function is only useful for arrays of chars which are a special case) - make_iterator_range(x, x+10) (the general-purpose mechanism to define ranges from iterators)