added sanity checks in ConditionalIterator

This commit is contained in:
Mathew Sutcliffe
2014-07-14 23:26:00 +01:00
parent 83b552faf6
commit f05c31871a
2 changed files with 13 additions and 1 deletions

View File

@@ -191,6 +191,12 @@ namespace BlackMisc
bool operator >=(const ConditionalIterator &other) const { return m_iterator >= other.m_iterator; }
//! @}
//! \private
void checkEnd(const ConditionalIterator &other) // debugging
{
Q_ASSERT(m_end == other.m_end && m_end == other.m_iterator);
}
private:
I m_iterator;
I m_end;

View File

@@ -124,7 +124,7 @@ namespace BlackMisc
//! @}
//! Constructor.
CRange(I begin, I end) : m_begin(begin), m_end(end) {}
CRange(I begin, I end) : m_begin(begin), m_end(end) { check(begin, end); }
//! Begin and end iterators.
//! @{
@@ -168,6 +168,12 @@ namespace BlackMisc
private:
I m_begin;
I m_end;
void check(...) {};
template <class I2, class F> void check(Iterators::ConditionalIterator<I2, F> begin, Iterators::ConditionalIterator<I2, F> end)
{
begin.checkEnd(end);
}
};
/*!