jeudi 1 janvier 2015

I have a T* addressing a buffer with len elements of type T. I need this data in the form of an std::vector<T>, for certain reasons. AFAICT, I construct a vector which uses my buffer as its internal storage. Why is that?


Notes:



  • Please don't suggest I use iterators - I know that's usually the way around such issues.

  • I don't mind that the vector might need to copy data around if it's resized later.

  • I'm asking about the reason, not about the possibility_

  • This question especially baffles me now that C++ has move semantics. If we can pull an object's storage from under its feet, why not be able to shove in our own?


Aucun commentaire:

Enregistrer un commentaire