title: Is it possible to return an a reference to the data in an std::vector, and preserve that reference after the vector goes out of scope?
body: <p>I am used to programming in C, and in that language I would just return a pointer to the data, and then the caller would be responsible for freeing the data, however, from what I've read, the vector's destructor will be called as soon as it goes out of scope, causing it's data to be de-allocated.</p>
  
  <p>Once the reference is returned, the size of the contents will not change, so if I could just have a pointer to the data that I could manually delete afterwards that would be ideal. What I really <em>do not</em> want to do is copy all of the data into a new container, since this vector is going to grow to be very large.</p>
  
  <p>Any help would be appreciated. Every solution I have seen so far involves either copying by value and relying on the compiler to optimize it, or using additional classes to wrap the vector.</p>
  
  <p>Edit: To be clear, the only part of the vector which I want to keep is a pointer to its data (I.E. the pointer you get using the vector.data() method), I don't need to keep any other information about the original vector.</p>