diff --git a/include/boost/archive/iterators/escape.hpp b/include/boost/archive/iterators/escape.hpp index d78de264..972e943c 100644 --- a/include/boost/archive/iterators/escape.hpp +++ b/include/boost/archive/iterators/escape.hpp @@ -53,12 +53,27 @@ class escape : typedef escape this_t; + void dereference_impl() { + m_current_value = static_cast(this)->fill(m_bnext, m_bend); + m_full = true; + } + + //Access the value referred to + reference_type dereference() const { + if(!m_full) + const_cast(this)->dereference_impl(); + return m_current_value; + } + bool equal(const this_t & rhs) const { - if(m_full && ! rhs.m_full) - rhs.dereference(); - else - if(! m_full && rhs.m_full) - dereference(); + if(m_full){ + if(! rhs.m_full) + const_cast(& rhs)->dereference_impl(); + } + else{ + if(rhs.m_full) + const_cast(this)->dereference_impl(); + } if(m_bnext != rhs.m_bnext) return false; if(this->base_reference() != rhs.base_reference()) @@ -66,19 +81,6 @@ class escape : return true; } - reference_type dereference_impl() { - if(!m_full){ - m_current_value = static_cast(this)->fill(m_bnext, m_bend); - m_full = true; - } - return m_current_value; - } - - //Access the value referred to - reference_type dereference() const { - return const_cast(this)->dereference_impl(); - } - void increment(){ if(++m_bnext < m_bend){ m_current_value = *m_bnext;