Can I create an std::vector
using my pre-existing data instead of it allocating new memory and copying the data?
To be clearer, if I have a memory area (either a c-array or part of another vector or whatever) and I want to provide vector-like access to it, can I create a vector and tell it to use this block of memory?
vector
or similar containers at all. Why do you want to put your data into a separate container? – Floruitvector<T>
, it will be avector<T,MyAllocator>
. So if the reason you need a vector is to pass it to some function that expects avector<T>
then that won't help you. If you need the vector for some other purpose then maybe it will help you. – Demars