C++ vector that *doesn't* initialize its members?

Posted by Mehrdad on Stack Overflow See other posts from Stack Overflow or by Mehrdad
Published on 2012-06-22T03:04:24Z Indexed on 2012/06/22 3:16 UTC
Read the original article Hit count: 106

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about c++

Related posts about stl