Subject: [Boost-bugs] [Boost C++ Libraries] #5888: [Documentation] iterator_facade docs -- const correctness problem.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-09-10 19:10:50
#5888: [Documentation] iterator_facade docs -- const correctness problem.
----------------------------------------------+-----------------------------
Reporter: Frank Erens <seysayux@â¦> | Owner: dave
Type: Bugs | Status: new
Milestone: To Be Determined | Component: iterator
Version: Boost 1.47.0 | Severity: Cosmetic
Keywords: |
----------------------------------------------+-----------------------------
On this documentation page, second box:
http://www.boost.org/doc/libs/1_47_0/libs/iterator/doc/iterator_facade.html#a
-constant-node-iterator there is a problem with const-correctness on the
dereference function.
For the const_node_iterator, Value = const node_base, thus yielding
{{{
const node_base& dereference() const {
return *m_node;
}
const node_base* m_node;
}}}
However, for node_iterator, Value = node_base:
{{{
node_base& dereference() const {
return *m_node; // Error: cannot convert const variable to non_const
reference
}
node_iterator* m_node;
}}}
Correct would be to const-overload dereference:
{{{
typedef boost::iterator_facade<
node_iter<Value>
, Value
, boost::forward_traversal_tag
> super;
typename super::reference dereference() {
return *m_node;
}
const typename super::reference dereference() const {
return *m_node;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5888> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC