cell_iterator - operator* const overloads

Users may still want to derederence a const iterator (note: not a const_iterator).
Also use the "reference" typedef to ensure there is only 1 source of information
This commit is contained in:
Crzyrndm 2018-05-31 13:16:54 +12:00
parent 098b0d8044
commit 45acf665e3
2 changed files with 19 additions and 3 deletions

View File

@ -89,7 +89,13 @@ public:
/// <summary>
/// Dereferences this iterator to return the cell it points to.
/// </summary>
cell operator*();
reference operator*();
/// <summary>
/// Dereferences this iterator to return the cell it points to.
/// </summary>
const reference operator*() const;
/// <summary>
/// Returns true if this iterator is equivalent to other.
@ -207,6 +213,12 @@ public:
/// destructor for const_cell_iterator
/// </summary>
~const_cell_iterator() = default;
/// <summary>
/// Dereferences this iterator to return the cell it points to.
/// </summary>
const reference operator*() const;
/// <summary>
/// Dereferences this iterator to return the cell it points to.
/// </summary>

View File

@ -265,14 +265,18 @@ const_cell_iterator const_cell_iterator::operator++(int)
return old;
}
cell cell_iterator::operator*()
cell_iterator::reference cell_iterator::operator*()
{
return ws_.cell(cursor_);
}
const cell const_cell_iterator::operator*() const
const cell_iterator::reference cell_iterator::operator*() const
{
return ws_.cell(cursor_);
}
const const_cell_iterator::reference const_cell_iterator::operator*() const
{
return ws_.cell(cursor_);
}
} // namespace xlnt