How can I reassign a boost multi_array_view to point to a different part of a multi_array? I don't want a deep copy.
boost::multi_array<int, 2> a(...);
array_view b = a[indices[index_range(0, 5)][index_range()]];
array_view c = a[indices[index_range(0, 10)][index_range()]];
b = c; // don't work
Boost source:
template <typename ConstMultiArray>
multi_array_ref& operator=(const ConstMultiArray& other) {
function_requires<
multi_array_concepts::
ConstMultiArrayConcept<ConstMultiArray,NumDims> >();
// make sure the dimensions agree
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
// iterator-based copy
std::copy(other.begin(),other.end(),this->begin());
return *this;
}
Update: I ended up changing the approach in my program to keep a reference to the indices object created by boost::indices[...]. Then I can use that object to create a new array_view at any time.