Opened 13 years ago

Closed 12 years ago

#3746 closed Bugs (fixed)

list_iterator::operator == fails to accept a non-const var to the left and a const one to the right

Reported by: gvlad@… Owned by: Ion Gaztañaga
Milestone: Boost 1.45.0 Component: intrusive
Version: Boost 1.41.0 Severity: Problem
Keywords: Cc:

Description

The following code fails to compile (msvc 9):

using namespace boost::intrusive; struct my_struct : list_base_hook<> {}; typedef list<my_struct> my_list; my_list l; my_list::const_iterator it = l.begin(); if (l.end() == it) {} fails if (it == l.end()) {} succeeds

If to use std::list there is no such problem because std::list::iterator is derived from std::list::const_iterator. My suggesion is to use template "operator ==" for list_iterator that accepts both const and non-const interator. For example:

("list_node.hpp") template <bool IsOtherConst> bool operator== (const list_iterator<Container, IsOtherConst>& i) const

{ return members_.nodeptr_ == i.pointed_node(); }

Change History (1)

comment:1 by Ion Gaztañaga, 12 years ago

Milestone: Boost 1.42.0Boost-1.45.0
Resolution: fixed
Status: newclosed

Fixed for Boost 1.45 in release branch

Note: See TracTickets for help on using tickets.