Boost C++ Libraries: Ticket #5191: intrusive unordered_set: const version of iterator_to() won't compile https://svn.boost.org/trac10/ticket/5191 <p> Discovered on 1_38_0 using g++ 4.3.2 on SuSE Linux Reproduced on 1_45_0 using g++ 4.2.1 on Macintosh (XCode) </p> <p> Reproduce by adding </p> <pre class="wiki"> MyClass const &amp;cr = values[0]; base_set.iterator_to(cr); </pre><p> to the bottom of the documentation example for unordered_set. </p> <p> iterator_to is trying to construct a const_iterator from a const bucket iterator, but this isn't supported by the iterator constructor. That lack of support by the iterator constructor seems to be by design (the internal bucket iterator is a non-const slist iterator). </p> <p> It appears that iterator_to is trying to call the non-cost priv_value_to_node by casting away the constness of the value param, but since the 'this' pointer is still const, the const version of priv_value_to_node is called instead. </p> <p> Removing the const_cast of hte value param, and adding a const_cast to the return value of priv_value_to_node seems to fix things just fine in 1_38_0. </p> <p> I tried changing: </p> <pre class="wiki"> return const_iterator(bucket_type::s_iterator_to( priv_value_to_node(const_cast&lt;reference&gt;(value))), this); </pre><p> to: </p> <pre class="wiki"> return const_iterator(bucket_type::s_iterator_to( const_cast&lt;node &amp;&gt;(priv_value_to_node(value))), this); </pre><p> in iterator_to in file boost/intrusive/hashtable.hpp (near line 1682 in 1_38_0) and it seems to be working just fine. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5191 Trac 1.4.3 Ion Gaztañaga Fri, 01 Apr 2011 17:18:42 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5191#comment:1 https://svn.boost.org/trac10/ticket/5191#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> Fixed in Boost 1.47 </p> Ticket