[Boost-bugs] [Boost C++ Libraries] #3746: list_iterator::operator == fails to accept a non-const var to the left and a const one to the right

Subject: [Boost-bugs] [Boost C++ Libraries] #3746: list_iterator::operator == fails to accept a non-const var to the left and a const one to the right
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-12-10 12:02:54


#3746: list_iterator::operator == fails to accept a non-const var to the left and
a const one to the right
--------------------------+-------------------------------------------------
 Reporter: gvlad@… | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: Boost 1.42.0 | Component: intrusive
  Version: Boost 1.41.0 | Severity: Problem
 Keywords: |
--------------------------+-------------------------------------------------
 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(); }

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3746>
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:02 UTC