Opened 11 years ago
Closed 11 years ago
#5915 closed Bugs (invalid)
boost::split replaces original data
Reported by: | Owned by: | Pavol Droba | |
---|---|---|---|
Milestone: | To Be Determined | Component: | string_algo |
Version: | Boost 1.47.0 | Severity: | Problem |
Keywords: | Cc: | jayen@… |
Description
Pseudo-ish code:
<code> std::vector<std::string> nodes; nodes.push_back("z"); boost::split(nodes, "a:b:c", ':'); </code>
After this, "z" is no longer a member of nodes due to a std::swap in iter_split. Result.insert(Result.end(), itBegin, itEnd) (or some equivalent) should probably be done instead. The docs state:
"Each part is copied and added as a new element to the output container."
Either the docs are incorrect or the code needs fixed.
Change History (3)
comment:1 by , 11 years ago
Cc: | added |
---|
comment:2 by , 11 years ago
comment:3 by , 11 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
The 1.48 documents at http://www.boost.org/doc/libs/1_48_0/doc/html/boost/algorithm/split_id1125874.html state:
Note: Prior content of the result will be overwritten.
Closing this as "Not a bug".
Confirmed with 1.48:
Prints: { a b c }