Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi_array] Access a view's index_range
From: Ronald Garcia (garcia_at_[hidden])
Date: 2008-10-09 19:55:43


Hi Robert,

The index_range object is used to create views, but it doesn't stay
around. However, all of the information from an index_range is still
accessible. You want to look into the following 3 MultiArray concept
functions: indices(), strides(), and shape().

Based on your code, it looks like you're trying to get the valid
indices for the array so you can dereference it.

If you're not changing the index base (meaning your array indices
always start at 0), then you want to write:

typedef Grid::array_view<2>::type view_t

...

for(view_t::index i = 0; i != view.size(); ++i) { ... }

HTH,
ron

On Oct 9, 2008, at 5:40 AM, Robert Jones wrote:

> How do I access the index_range of an array_view? ie.,
>
> typedef boost::multi_array<Cell,2 > Grid;
> Grid grid( boost::extents[9][9]);
> Grid::array_view<2> view = grid[indices[range(), range()]];
>
> for (Grid::index i = view.?????.start(); i != view.?????.finish(); +
> +i)
> {....}
>
> where I'm expecting i to take values 0..8 inclusive.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net