Boost C++ Libraries: Ticket #6073: typed subarray from incompatible/raw memory https://svn.boost.org/trac10/ticket/6073 <p> Consider this example: </p> <pre class="wiki">struct A { double x, y; }; struct B : A { double z; }; struct C { A a; double z; }; struct D { double z; A a; }; struct unknown { ...; A a; ....; }; </pre><p> Let's say I have in memory an n-dimensional array of B, or C, or D, or even unknown structure where I know only total size of the element and offset of A inside it, both in run-time (e.g. a binary file produced by <a class="missing wiki">NumPy</a>.mmap). </p> <p> What I need is a multi_array_view that could behave as an multi_array of A, given the sizeof of "real" element containing A, and offset of A inside it, like this: </p> <pre class="wiki">void* p = mmap(...); size_t el_size = size_of_element_in_p; size_t offset = offset_of_A_inside_element; boost::multi_array::multi_array_typed_view&lt;A, NumDims&gt; my_view(p, extents, el_size, offset ); </pre><p> Strided view (boost::detail::multi_array::multi_array_view) could do the job in simple cases when size of "real" element is a multiple of sizeof(A), but not in the above case. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6073 Trac 1.4.3