Boost C++ Libraries: Ticket #6714: utree::insert return begin() if position == end() https://svn.boost.org/trac10/ticket/6714 <p> This seems intentional by looking at the source, but it makes utree::insert differ from stl in a subtle and very dangerous way. It also makes using insert excessively cumbersome, as you need to special case for position == end. Offending function is at BOOST/SPIRIT/HOME/SUPPORT/UTREE/DETAIL/UTREE_DETAIL2.HPP @ ~1037 ( inline utree::iterator utree::insert(iterator pos, T const&amp; val) ). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6714 Trac 1.4.3 Joel de Guzman Tue, 20 Mar 2012 13:45:29 GMT <link>https://svn.boost.org/trac10/ticket/6714#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6714#comment:1</guid> <description> <p> That's incorrect. Insert only returns begin() IF position == end() AND the container is empty. There is nothing wrong with the logic as it is. If you don't agree, feel free to attach a test case that proves that the logic is wrong. Please do so ASAP. I do not want to have lingering open issues. Thanks. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 20 Mar 2012 14:04:42 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6714#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6714#comment:2</guid> <description> <p> That does not seem to be the case. The following fails for me: </p> <pre class="wiki">#include "boost/spirit/home/support/utree.hpp" #include &lt;cassert&gt; int main() { boost::spirit::utree ut; ut.push_back(1); assert( ut.insert( ut.end(), 1 ) != ut.begin() ); } </pre><p> If one takes a look at boost::utree::end() it creates an iterator with 0 as node ( makes sense I presume ). The guard is then: </p> <pre class="wiki">if (!pos.node) { l.push_back(val); return utree::iterator(l.first, 0); // begin(); } </pre><p> As pos.node == 0 for all end() it would seem it doesn't matter how many items are in the utree. Perhaps I'm missing something? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Tue, 20 Mar 2012 15:16:06 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6714#comment:3 https://svn.boost.org/trac10/ticket/6714#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">fixed</span> </li> </ul> <p> No, you are right and I am blind! Fixed in trunk. Please verify; tests added. </p> Ticket