What is the difference between boost::split
and boost::iter_split
functions?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With