I have a raw pointer, say,
char * ptr = (char *) malloc(LIMIT);
fill_with_data(ptr, LIMIT, &size);
auto v = vector<char>(ptr, ptr + size);
std::vector ¹can't use an existing buffer.
If you want to automate the lifetime management of an existing buffer you can use a smart pointer such as
¹ It's technically possible to use a custom allocator to trick a
std::vector into using an existing buffer, but exposing the data in that buffer would have to rely on non-portable aspects of the implementation.