Boost C++ Libraries: Ticket #11628: small_vector<int,n> iterates over elements in destructor https://svn.boost.org/trac10/ticket/11628 <p> In the destruction of a small_vector&lt;int,10&gt;, gdb reveals that the integers are individually destroyed, which makes destruction linear in the size of the object. </p> <p> The code that does this linear-time destruction is the code below from container/detail/copy_move_algo.hpp: </p> <p> template </p> <blockquote> <p> &lt;typename Allocator, </p> <blockquote> <p> typename I, <em> I models <a class="missing wiki">InputIterator</a> </em></p> </blockquote> <p> ,typename U&gt; <em> U models unsigned integral constant </em></p> </blockquote> <p> inline typename container_detail::disable_if_trivially_destructible&lt;I, void&gt;::type destroy_alloc_n(Allocator &amp;a, I f, U n) { while(n--){ </p> <blockquote> <p> allocator_traits&lt;Allocator&gt;::destroy(a,container_detail::iterator_to_raw_pointer(f)); ++f; </p> </blockquote> <p> } </p> <p> Since int is a POD type, it seems that this loop shouldn't be executed. It appears that the type variable I takes on the value "int*". </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11628 Trac 1.4.3 benjamin.redelings@… Tue, 08 Sep 2015 22:43:41 GMT attachment set https://svn.boost.org/trac10/ticket/11628 https://svn.boost.org/trac10/ticket/11628 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test2.C</span> </li> </ul> <p> test case </p> Ticket Ion Gaztañaga Wed, 09 Sep 2015 07:55:57 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11628#comment:1 https://svn.boost.org/trac10/ticket/11628#comment:1 <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> Thanks for the report. It seems that the trait that avoids the linear iteration was commented in a test and committed inadvertently. Fixed in: </p> <p> <a class="ext-link" href="https://github.com/boostorg/container/commit/f1f97518d338c7f7351308aa1785ebae5f2ddde7"><span class="icon">​</span>https://github.com/boostorg/container/commit/f1f97518d338c7f7351308aa1785ebae5f2ddde7</a> </p> Ticket