27 #ifndef CELLITERATORS_H 
   28 #define CELLITERATORS_H 
   32 #include <type_traits> 
   35   static_assert(std::is_class<Cell>::value, 
"The type argument must be a class");
 
   47     return operator++(), ret;
 
   53       auto *
const prev = m_ptr;
 
   55       wxASSERT(prev != m_ptr);
 
   60     return m_ptr == o.m_ptr;
 
   63     return m_ptr != o.m_ptr;
 
   65   constexpr 
operator bool()
 const { 
return m_ptr; }
 
   66   constexpr 
operator Cell *() 
const { 
return m_ptr; }
 
   67   constexpr 
Cell *operator->()
 const { 
return m_ptr; }
 
   71   static_assert(std::is_class<Cell>::value, 
"The type argument must be a class");
 
   79   constexpr 
iterator end()
 const { 
return {}; }
 
   84 template <
typename Cell>
 
   86   static_assert(std::is_class<Cell>::value, 
"The type argument must be a class");
 
   97     return operator++(), ret;
 
  104       auto *
const prev = m_ptr;
 
  106       wxASSERT(prev != m_ptr);
 
  111   { 
return m_ptr == o.m_ptr; }
 
  113   { 
return m_ptr != o.m_ptr; }
 
  114   constexpr 
operator bool()
 const { 
return m_ptr; }
 
  115   constexpr 
operator Cell*() 
const { 
return m_ptr; }
 
  116   constexpr 
Cell *operator->()
 const { 
return m_ptr; }
 
  121   static_assert(std::is_class<Cell>::value, 
"The type argument must be a class");
 
  129   constexpr 
iterator end()
 const { 
return {}; }
 
  139   enum class Advance { Always, OnlyIfNull };
 
  140   const Cell *m_parentCell = {};
 
  141   Cell *m_innerCell = {};
 
  143   int16_t m_endIndex = 0;
 
  145   static int GetInnerCellCount(
const Cell *cell);
 
  146   static Cell *GetInnerCell(
const Cell *cell, 
int index);
 
  150     m_parentCell(parentCell),
 
  151     m_endIndex(parentCell ? GetInnerCellCount(parentCell) : 0)
 
  153     FindFirstInnerCell();
 
  160     return operator++(), ret;
 
  165       AdvanceLoop(Advance::Always);
 
  169   { 
return m_innerCell == o.m_innerCell; }
 
  171   { 
return m_innerCell != o.m_innerCell; }
 
  172   operator bool()
 const { 
return m_innerCell; }
 
  173   operator Cell*() 
const { 
return m_innerCell; }
 
  174   Cell *operator->()
 const { 
return m_innerCell; }
 
  177   void FindFirstInnerCell();
 
  178   void AdvanceLoop(Advance mode);
 
  181 inline void InnerCellIterator::FindFirstInnerCell()
 
  185     m_innerCell = GetInnerCell(m_parentCell, 0);
 
  186     AdvanceLoop(Advance::OnlyIfNull);
 
  190 inline void InnerCellIterator::AdvanceLoop(Advance mode)
 
  192   Cell *prev = m_innerCell;
 
  193   if (mode == Advance::OnlyIfNull && prev)
 
  198     if (m_index == m_endIndex)
 
  200       m_innerCell = 
nullptr;
 
  203     m_innerCell = GetInnerCell(m_parentCell, m_index);
 
  204     wxASSERT(!prev || prev != m_innerCell);
 
  217   iterator begin()
 const { 
return m_iter; }