Boost C++ Libraries: Ticket #5888: [Documentation] iterator_facade docs -- const correctness problem. https://svn.boost.org/trac10/ticket/5888 <p> On this documentation page, second box: <a href="http://www.boost.org/doc/libs/1_47_0/libs/iterator/doc/iterator_facade.html#a-constant-node-iterator">http://www.boost.org/doc/libs/1_47_0/libs/iterator/doc/iterator_facade.html#a-constant-node-iterator</a> there is a problem with const-correctness on the dereference function. </p> <p> For the const_node_iterator, Value = const node_base, thus yielding </p> <pre class="wiki">const node_base&amp; dereference() const { return *m_node; } const node_base* m_node; </pre><p> However, for node_iterator, Value = node_base: </p> <pre class="wiki">node_base&amp; dereference() const { return *m_node; // Error: cannot convert const variable to non_const reference } node_iterator* m_node; </pre><p> Correct would be to const-overload dereference: </p> <pre class="wiki">typedef boost::iterator_facade&lt; node_iter&lt;Value&gt; , Value , boost::forward_traversal_tag &gt; super; typename super::reference dereference() { return *m_node; } const typename super::reference dereference() const { return *m_node; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5888 Trac 1.4.3 anonymous Mon, 10 Oct 2011 23:36:12 GMT <link>https://svn.boost.org/trac10/ticket/5888#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5888#comment:1</guid> <description> <p> On this same example snippet, the explicit constructor is: </p> <pre class="wiki"> explicit const_node_iterator(node_base* p) : m_node(p) {} </pre><p> but it should be </p> <pre class="wiki"> explicit const_node_iterator(const node_base* p) : m_node(p) {} </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Dave Abrahams</dc:creator> <pubDate>Wed, 21 Nov 2012 22:17:18 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/5888#comment:2 https://svn.boost.org/trac10/ticket/5888#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Dave Abrahams</span> to <span class="trac-author">jeffrey.hellrung</span> </li> </ul> Ticket