I have a raw pointer, say,
char * ptr = (char *) malloc(LIMIT);
size_t size;
fill_with_data(ptr, LIMIT, &size);
Now I'd like to wrap the pointer data using std::vector.
auto v = vector<char>(ptr, ptr + size);
But I think using the syntax above will produce a copy of the pointer's contents. Is there any way to convert a raw pointer to vector without duplicating the data in memory?
Aucun commentaire:
Enregistrer un commentaire