Boost C++ Libraries: Ticket #5915: boost::split replaces original data https://svn.boost.org/trac10/ticket/5915 <p> Pseudo-ish code: </p> <p> &lt;code&gt; std::vector&lt;std::string&gt; nodes; nodes.push_back("z"); boost::split(nodes, "a:b:c", ':'); &lt;/code&gt; </p> <p> 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: </p> <p> "Each part is copied and added as a new element to the output container." </p> <p> Either the docs are incorrect or the code needs fixed. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5915 Trac 1.4.3 jayen <jayen@…> Tue, 01 Nov 2011 07:08:11 GMT cc set https://svn.boost.org/trac10/ticket/5915#comment:1 https://svn.boost.org/trac10/ticket/5915#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">jayen@…</span> added </li> </ul> Ticket Marshall Clow Mon, 19 Dec 2011 19:09:19 GMT <link>https://svn.boost.org/trac10/ticket/5915#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5915#comment:2</guid> <description> <p> Confirmed with 1.48: </p> <pre class="wiki">#include &lt;stdexcept&gt; #include &lt;iostream&gt; #include &lt;string&gt; #include &lt;vector&gt; template &lt;class Container&gt; void print ( const Container &amp;c ) { std::cout &lt;&lt; "{ "; for ( typename Container::const_iterator iter = c.begin (); iter != c.end (); ++iter ) std::cout &lt;&lt; *iter &lt;&lt; " "; std::cout &lt;&lt; "}" &lt;&lt; std::endl; } #include &lt;boost/algorithm/string/classification.hpp&gt; #include &lt;boost/algorithm/string/split.hpp&gt; int main ( int argc, char *argv [] ) { std::vector&lt;std::string&gt; nodes; nodes.push_back ("z"); print (nodes); boost::split (nodes, "a:b:c", boost::is_any_of(":")); print (nodes); return 0; } </pre><p> Prints: { a b c } </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Mon, 19 Dec 2011 22:35:11 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5915#comment:3 https://svn.boost.org/trac10/ticket/5915#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> The 1.48 documents at <a href="http://www.boost.org/doc/libs/1_48_0/doc/html/boost/algorithm/split_id1125874.html">http://www.boost.org/doc/libs/1_48_0/doc/html/boost/algorithm/split_id1125874.html</a> state: </p> <p> Note: Prior content of the result will be overwritten. </p> <p> Closing this as "Not a bug". </p> Ticket