Which is a better c++ container for holding and accessing binary data?
std::vector
or
std::string
Is one more efficient than the other?
This is the wrong question.
Is one a more 'correct' usage?
This is the correct question.
It depends. How is the data being used? If you are going to use the data in a string like fashon then you should opt for std::string as using a std::vector may confuse subsequent maintainers. If on the other hand most of the data manipulation looks like plain maths or vector like then a std::vector is more appropriate.
You should prefer std::vector over std::string
. In common cases both solutions can be almost equivalent, but std::string
s are designed specifically for strings and string manipulation and that is not your intended use.
Compare this 2 and choose yourself which is more specific for you. Both are very robust, working with STL algorithms ... Choose yourself wich is more effective for your task