keep_alive to non-argument and non-return value #4139
-
hello! I'm having a hard time getting this to work. What this method does is copies the vector, clears the original vector, and then returns an iterator of the copied vector.
At the moment of executing this function, contrary to my wish, "copy" is freed and an error occurs as soon as it returns, because std::iterator does not refer to "copy". I've read the keep_alive documentation, but this seems to only apply to arguments and return values. Is there any way to apply a similar approach to other variables? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I solved it by returning a vector and defining an iter of the vector. |
Beta Was this translation helpful? Give feedback.
I solved it by returning a vector and defining an iter of the vector.