vector< char>的优点过字符串? [英] Benefits of vector<char> over string?
问题描述
此问题与此问题有关,但不完全相同。
使用 std :: vector< char>
而不是 std :: string
保持任意二进制数据,搁置与可读性相关的问题?
ie
是的, code>向下< char> c>
$ b
它不能使用小缓冲区优化,但另一方面必须在<$ 期间保留迭代器,引用等c $ c> swap 操作。
请参阅: 可以 std :: vector
使用小缓冲区优化?
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 over string
.
It must not use the small buffer optimizations, but on the other hand it must preserve iterators, references, etc. during a swap
operation.
See: May std::vector
make use of small buffer optimization?
这篇关于vector< char>的优点过字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!