
Mathias Gaunard wrote:
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)
You're correct, I could just use: sum (boost::make_iterator_range (x, x+size)); But, these don't compile: sum (boost::make_iterator_range<double const*> (x, x+size)); sum (boost::make_iterator_range<double *> (x, x+size)); I'm stumped. The reason I need this, is I will need the type of range returned by boost::make_iterator_range (double*, double*). Apparantly, it's not boost::iterator_range<double*>.