Opened 11 years ago
Last modified 10 years ago
#5888 new Bugs
[Documentation] iterator_facade docs -- const correctness problem.
Reported by: | Owned by: | jeffrey.hellrung | |
---|---|---|---|
Milestone: | To Be Determined | Component: | iterator |
Version: | Boost 1.47.0 | Severity: | Cosmetic |
Keywords: | Cc: |
Description
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; }
Note:
See TracTickets
for help on using tickets.
On this same example snippet, the explicit constructor is:
but it should be