[MultiArray] shape() return type

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Has there ever been any thought to making multi_array::shape() return something that models the Collection concept (RandomAccessCollection in particular I suppose) rather than a raw pointer? This would allow the return value from shape() to be passed directly to multi_array::reshape() or multi_array::resize(), for added convenience. It would also allow a debug assertion to be added to make sure you don't try to access beyond the end of the array returned by shape(). -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkpDxwoACgkQ5vihyNWuA4UrlACcDd/AZgM4lab3pFu96TJsc9Om 6O0AoL4DCYxWtsNBJBdvaVwp/n3p5h80 =6Wss -----END PGP SIGNATURE-----

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday 25 June 2009, Frank Mori Hess wrote:
Has there ever been any thought to making multi_array::shape() return something that models the Collection concept (RandomAccessCollection in particular I suppose) rather than a raw pointer? This would allow the return value from shape() to be passed directly to multi_array::reshape() or multi_array::resize(), for added convenience. It would also allow a debug assertion to be added to make sure you don't try to access beyond the end of the array returned by shape().
Attached is some code to lay out what I have in mind for a RandomAccessCollection-returning shape() for multi_array. It includes an adapter which allows a C array to be accessed as a RandomAccessCollection, plus some free functions which I use to modify the return value from multi_array::shape() to be what I wish shape() returned in the first place. For backwards compatibility, maybe a RandomAccessCollection-returning shape() could be added to multi_array with a different name and shape() deprecated? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkpE52MACgkQ5vihyNWuA4XElQCfYlyZFGrD+XBvwoWxj6w4Rgqo a8EAoLGKQP9oOo2SS4vaushdJ3cOEZom =z0Gn -----END PGP SIGNATURE-----

Hi Frank, Yes, I have considered such a thing, though rather than returning a collection specifically, I have considered upgrading multi_array to use the Boost.Range concepts. Then there could be versions of shape, indices, etc. that return a pair of pointers, which could be treated as Ranges. Ron On Jun 25, 2009, at 1:50 PM, Frank Mori Hess wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Has there ever been any thought to making multi_array::shape() return something that models the Collection concept (RandomAccessCollection in particular I suppose) rather than a raw pointer? This would allow the return value from shape() to be passed directly to multi_array::reshape() or multi_array::resize(), for added convenience. It would also allow a debug assertion to be added to make sure you don't try to access beyond the end of the array returned by shape().
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkpDxwoACgkQ5vihyNWuA4UrlACcDd/AZgM4lab3pFu96TJsc9Om 6O0AoL4DCYxWtsNBJBdvaVwp/n3p5h80 =6Wss -----END PGP SIGNATURE----- _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Frank Mori Hess
-
Ronald Garcia