GEOS-DEV/LvArray

Disalow creation of views and slices from rvalues.

Closed this issue · 1 comments

You should not be able to create an ArrayView or an ArraySlice from a Array && and you should not be able to create an ArraySlice from an ArrayView &&. Similarly for the other classes. This includes the creation of ArraySlice from the operator[] but not from CRSMatrixView::getEntries.

At the same time it would be nice to see if there's an easy way to disable the conversion from Array to ArrayView &. If this involves making ArrayView a protected base class then a separate issue should be made.

It appears to be impossible to allow the conversion from Array to ArrayView const & while prohibiting the conversion to ArrayView &. The only way to prohibit ArrayView & is to make ArrayView a protected base class but this would also prohibit the conversion to ArrayView const &. I would be OK with this decision but there are valid use cases for getting an ArrayView const & instead of ArrayView const out of an Array.

https://stackoverflow.com/questions/44864106/user-defined-conversion-operator-to-inaccessible-base-class