Boost C++ Libraries: Ticket #2423: map_array insert has invalid assertion https://svn.boost.org/trac10/ticket/2423 <p> The external logic check in here appears to be wrong. The check is applied when the code sees the need to insert a new element in the underlying representation 'in the middle' -- the lower bound does not return end, and and the slot it returns does not have the correct index. The check requires the map to be empty or that the iterator is at the end, thus refusing to insert into the middle. </p> <blockquote> <p> <em> Form Unique Associative Container concept </em></p> <blockquote> <p> <em> BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. std::pair&lt;iterator,bool&gt; insert (const value_type &amp;p) { </em></p> <blockquote> <p> iterator it = detail::lower_bound (begin (), end (), p, detail::less_pair&lt;value_type&gt; ()); if (it != end () &amp;&amp; it-&gt;first == p.first) </p> <blockquote> <p> return std::make_pair (it, false); </p> </blockquote> <p> difference_type n = it - begin (); </p> <table class="wiki"> <tr>BOOST_UBLAS_CHECK (size () == 0 <td> size () == size_type (n), external_logic ()); </td></tr></table> <p> resize (size () + 1); it = begin () + n; <em> allow for invalidation std::copy_backward (it, end () - 1, end ()); *it = p; return std::make_pair (it, true); </em></p> </blockquote> <p> } </p> </blockquote> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2423 Trac 1.4.3 Gunter Mon, 20 Oct 2008 21:44:08 GMT status changed https://svn.boost.org/trac10/ticket/2423#comment:1 https://svn.boost.org/trac10/ticket/2423#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Replying to <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2423" title="#2423: Bugs: map_array insert has invalid assertion (closed: fixed)">benson margulies &lt;bimargulies@gmail.com&gt;</a>: </p> <blockquote class="citation"> <p> The external logic check in here appears to be wrong. The check is applied when the code sees the need to insert a new element in the underlying representation 'in the middle' -- the lower bound does not return end, and and the slot it returns does not have the correct index. The check requires the map to be empty or that the iterator is at the end, thus refusing to insert into the middle. </p> </blockquote> <p> I see your point. Can you provide an example where the check fails although it should succeed? </p> <p> (BTW: No one seems to use map_array any more because std::map can be used instead.) </p> Ticket benson margulies <bimargulies@…> Tue, 21 Oct 2008 00:15:41 GMT <link>https://svn.boost.org/trac10/ticket/2423#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2423#comment:2</guid> <description> <p> I'm reasonably certain that all you have to do is insert out of order: 1, 10, 5. If that doesn't cooperate for you, I'll cook you a test case? </p> <p> std::map has incredibly slow performance for iteration. If, like me, you need to rapidly iterate over the occupied slots of the sparse data structure, std::map is awful. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Gunter</dc:creator> <pubDate>Mon, 03 Nov 2008 22:53:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2423#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2423#comment:3</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/49578" title="see #2423. removed the check because it makes absolutely no sense ...">[49578]</a>) see <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2423" title="#2423: Bugs: map_array insert has invalid assertion (closed: fixed)">#2423</a>. removed the check because it makes absolutely no sense TODO: check the strange "optimization" of lower bound. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Gunter</dc:creator> <pubDate>Mon, 09 Mar 2009 20:29:47 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/2423#comment:4 https://svn.boost.org/trac10/ticket/2423#comment:4 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.37.0</span> → <span class="trac-field-new">Boost 1.39.0</span> </li> </ul> <p> merged changes into release branch </p> Ticket Gunter Thu, 18 Jun 2009 07:47:22 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2423#comment:5 https://svn.boost.org/trac10/ticket/2423#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> The fix seems to work without side effects. Thus I close this issue. </p> Ticket