c++ - What are differences between std::string and std::vector<char>? -


so main differences , of them used in cases?

  • vector<char> gives guarantee &v[0]+n == &v[n] whereas string doesn't (practically, case, there no guarantee)... afaik c++0x gives guarantee already
  • there no implicit conversion const char* vector<char>
  • string not stl container. example, has no pop_back() or back() functions
  • and last, not least, different member functions! string gives functions suitable strings, returnig null-terminated string c_str()

bottom line: use string when need operate strings. use vector<char> when need ... well, vector of individual chars...

another use of vector<char> way avoid vector<bool> specialization.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -