Skip to content

make_ArrayHandle(std::vector<>) should deep copy by default

The make_ArrayHandle function that takes an std::vector just gets a shallow copy of the pointer and builds the ArrayHandle from that. This is the most efficient way to do it, but it is dangerous because the memory is no longer managed by the ArrayHandle. Specifically, if the the std::vector goes out of scope, the ArrayHandle becomes invalid. It will fail, indeterminately, later. This has caused lots of problems.

Consequently, it would be better if make_ArrayHandle by default does a deep copy of the std::vector. There should still be a buyer beware form (perhaps with an optional second argument) where the user can do a shallow copy.