vendredi 1 avril 2016

Is it possible that a pointer gets owned by a vector without any data copy?

If I have a C type raw pointer, is it possible to create a std::vector from the same type that owns the pointer's data without any data copy (only moving)? What motivates me for asking this question is the existence of data() member function for std::vector which means vector's elements are residing somewhere in the memory consecutively.

Edit: I have to add that the hope I had was also intensified by the existence of functions like std::make_shared.

Aucun commentaire:

Enregistrer un commentaire