的boost ::分裂之间的差值Vs的boost :: iter_split [英] Difference between boost::split vs boost::iter_split
问题描述
什么是的boost ::拆分
和的boost :: iter_split
功能?
推荐答案
的boost ::拆分
将分割字符串到 SequenceSequenceT
(例如,的std ::矢量<标准::字符串>
)。 的boost :: iter_split
地方迭代器
(具体迭代器范围)到 SequenceSequenceT
。
boost::split
copies the split string into the SequenceSequenceT
(for example, a std::vector<std::string>
). boost::iter_split
places iterators
(specifically, iterator ranges) into the SequenceSequenceT
.
这实际上意味着两件事情:
This effectively means two things:
-
使用
拆分
将创建一个副本,因此,以字符串返回容器中的任何更改将不被原始字符串可以看出。此外,您不必担心迭代器失效。
Using
split
will create copies, hence any changes to the returned container of strings won't be seen by the original string. Also, you don't need to worry about iterator invalidation.
使用 iter_split
会给后面的迭代器范围的容器,因此,修改一下这些迭代器指向也将修改原始字符串。其次,如果原始字符串修改运行后 iter_split
,你可能会遇到迭代器失效的问题。但是,没有副本的基础字符串上进行的,所以这可能会稍微更快地运行并使用更少的内存。
Using iter_split
will give back a container of iterator ranges, hence, modifying what these iterators point to will also modify the original string. Secondly, if the original string is modified after you run iter_split
, you could run into iterator invalidation issues. However, no copies are performed on the underlying string, so this will likely run slightly faster and use less memory.
这篇关于的boost ::分裂之间的差值Vs的boost :: iter_split的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!