This question is related to, but not quite the same as, this question.
Are there any benefits to using std::vector<char> instead of std::string to hold arbitrary binary data, aside from readability-related issues?
i.e. Are there any tasks which are easier/more efficient/better to perform with a vector compared to a string?
Yes,
vector<char>indeed does have more capabilities overstring.Unlike
string,vector<char>is guaranteed to preserve iterators, references, etc. during aswapoperation. See: Maystd::vectormake use of small buffer optimization?