Subject: Re: [boost] [range] flat_array_view feature request.
From: John M. Dlugosz (mpbecey7gu_at_[hidden])
Date: 2014-01-06 13:52:55
On 1/3/2014 5:13 AM, Mostafa wrote:
> I think having a flat_array_view adapter in boost would be helpful. Something along the
> lines of https://github.com/m-w-a/sandbox/blob/master/flat_array_view.cc What do the
> maintainer(s) of Range and others think?
I'd love to see more done with Range.
The flattener I think should work with any mult-dim array-like thing; not just primitive
arrays, but std::array (nee boost::container::array).
If the kind of thing imposes that all the elements have the same size, that makes it easy
to random access. But I agree with another poster that it's really a special case of any
kind of ragged thing. A bidirectional iterator could handle any shape of recursive
ordered containers. (You'd have to use type-erasure techniques to handle different number
of levels and/or different composition in different elements. Ah, but strong typing
normally means you'll have the same number of dimensions and container type for each
dimension, all the way down. Only the use of non-fixed-size containers have to be dealt
with; any "this or that" containers would already come with their own iterators.)
I think writing that to work for any range of ranges will have side benefits, in making
other primitive metafunctions fully general (e.g. remove_extent)
I see that for a multi-dim primitive array it is particularly simple to view with
different organization of the same number of elements, since they are really flat
internally. For such arrays, a more general thing would be a redim facade that acts like
a fixed-size container. Flat would be a special case of that, and people would more
naturally accept that it's for arrays only.
(A fully general flattening of ranges could be done with iterating a recursive 'join')
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk