C++ vector that *doesn't* initialize its members?
- by Mehrdad
I'm making a C++ wrapper for a piece of C code that returns a large array, and so I've tried to return the data in a vector<unsigned char>.
Now the problem is, the data is on the order of megabytes, and vector unnecessarily initializes its storage, which essentially turns out to cut down my speed by half.
How do I prevent this?
Or, if it's not possible -- is there some other STL container that would avoid such needless work? Or must I end up making my own container?
(Pre-C++11)
Note:
I'm passing the vector as my output buffer. I'm not copying the data from elsewhere.