Re: [Boost-users] multi_array: creating a view to a single element
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Cromwell Enage
Would T & center = element[3][3] be satisfactory?
Try:
typename boost::multi_array
::index index1 = (element.index_bases()[0] + element.strides()[0]) / 2; typename boost::multi_array ::index index2 = element.index_bases()[1]; + element.strides()[1]) / 2; T& center = element[index1][index2];
To make it general, yes.
I don't think multiarray supports any type of reallocation after construction, so it should be ok.
boost::multi_array has a resize() function, if that's what you're afraid of. See http://www.boost.org/libs/multi_array/doc/reference.html
In this case, obviously center would not be center anymore, so the OP should beware.
participants (1)
-
Sohail Somani