Add non default copy constructor and assignment operator for GeoGrid::GridView
Currently the class GeoGrid::GridView
has no explicit implementation of copy constructor and copy assignment operator and therefore default versions are used. But these are not always sufficient, since the stored index set is essentially a pointer to the host index set. For example creating an object of type GeometryGrid<GeometryGrid<...>, ...>
and using the copy constructor or copy assignment operator of the corresponding grid view can lead to a segmentation fault. (In this example the index set of the new created / reassigned grid view will point to the host grid view of the old (copied) grid view which possibly no longer exists.) Providing explicit implementations of the copy constructor and copy assignment operator as shown in the following snippet should fix this problem:
GridView( const This &other )
: grid_( other.grid_ ),
hostGridView_( other.hostGridView_ ),
// indexSet_ contains a pointer to host index set, so copying this can be dangerous in case we create GeometryGrid<GeometryGrid<...>, ...>
indexSet_()
{}
This & operator=( const This &other) {
grid_ = other.grid_;
hostGridView_ = other.hostGridView_;
// indexSet_ contains a pointer to host index set, so assigning it from other.indexSet_ can be dangerous in case we create GeometryGrid<GeometryGrid<...>, ...>
indexSet_ = IndexSet{};
}