[Boost-bugs] [Boost C++ Libraries] #7376: join_iterator.hpp compiler warning

Subject: [Boost-bugs] [Boost C++ Libraries] #7376: join_iterator.hpp compiler warning
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-09-13 20:52:19


#7376: join_iterator.hpp compiler warning
-----------------------------------------------------+----------------------
 Reporter: Leonid Gershanovich <gleonid@…> | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.51.0
 Severity: Problem | Keywords:
-----------------------------------------------------+----------------------
 getting compiler warning in boost/range/detail/join_iterator.hpp:74

 {{{
 53 template<typename Iterator1
 54 , typename Iterator2
 55 , typename Reference
 56 >
 57 class join_iterator_union
 58 {
 59 public:
 60 typedef Iterator1 iterator1_t;
 61 typedef Iterator2 iterator2_t;
 62
 63 join_iterator_union() {}
 64 join_iterator_union(unsigned int /*selected*/, const iterator1_t&
 it1, const iterator2_t& it2) : m_it1(it1), m_it2(it2) {}
 65
 66 iterator1_t& it1() { return m_it1; }
 67 const iterator1_t& it1() const { return m_it1; }
 68
 69 iterator2_t& it2() { return m_it2; }
 70 const iterator2_t& it2() const { return m_it2; }
 71
 72 Reference dereference(unsigned int selected) const
 73 {
 74 return selected ? *m_it2 : *m_it1;
 75 }
 76
 77 bool equal(const join_iterator_union& other, unsigned int selected)
 const
 78 {
 79 return selected
 80 ? m_it2 == other.m_it2
 81 : m_it1 == other.m_it1;
 82 }
 83
 84 private:
 85 iterator1_t m_it1;
 86 iterator2_t m_it2;
 87 };
 }}}


 I am using it in a way when iterator1_t and iterator1_t are different
 types. Furthermore, underlying types (*m_it1 and *m_it2) are different,
 but both are convertible to '''Reference''', but not to each other.

 In other words expression '''*m_it2''' cannot be converted to type
 iterated by '''iterator1_t''' ( *m_it1 ). But can be safely converted to
 type '''Reference'''

 please consider following patch:
 {{{
 @@ -68,7 +68,9 @@

      Reference dereference(unsigned int selected) const
      {
 - return selected ? *m_it2 : *m_it1;
 + if (selected)
 + return *m_it2;
 + return *m_it1;
      }

      bool equal(const join_iterator_union& other, unsigned int selected)
 const
 }}}

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