I have an array of data in a C++/CLI array that I can pass to a native function using pin_ptr<T>
, no problem so far. Now, however, I need to pass the array on to a C++/STL function that expects a container such as std::array
or std::vector
.
The easy way of doing this (which I did first), is to copy element by element.
The second-easiest way is to call std::copy()
, see the answer to this question: convert System::array to std::vector.
However, I want to skip the entire copying step and just use the pointer instead. Seeing as std::array
requires a template argument to determine its length, I can't create one at runtime (but please do correct me if I'm wrong). Is there a way to create a vector or a different type of STL container, without unnecessary copying of data?