From fcca46012e081195e22c6028c17720382bf99cfe Mon Sep 17 00:00:00 2001 From: Crzyrndm Date: Thu, 31 May 2018 13:18:39 +1200 Subject: [PATCH] cell iterator - add operator-> Implementation just forwards to operator*, but this is a typical operator in the iterator API and is suprising and inconvenient that it is not present --- include/xlnt/worksheet/cell_iterator.hpp | 11 ++++++++++- source/worksheet/cell_iterator.cpp | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/xlnt/worksheet/cell_iterator.hpp b/include/xlnt/worksheet/cell_iterator.hpp index b11818f6..9e179057 100644 --- a/include/xlnt/worksheet/cell_iterator.hpp +++ b/include/xlnt/worksheet/cell_iterator.hpp @@ -96,6 +96,15 @@ public: /// const reference operator*() const; + /// + /// Dereferences this iterator to return the cell it points to. + /// + reference operator->(); + + /// + /// Dereferences this iterator to return the cell it points to. + /// + const reference operator->() const; /// /// Returns true if this iterator is equivalent to other. @@ -222,7 +231,7 @@ public: /// /// Dereferences this iterator to return the cell it points to. /// - const cell operator*() const; + const reference operator->() const; /// /// Returns true if this iterator is equivalent to other. diff --git a/source/worksheet/cell_iterator.cpp b/source/worksheet/cell_iterator.cpp index e4c334e9..d1f66252 100644 --- a/source/worksheet/cell_iterator.cpp +++ b/source/worksheet/cell_iterator.cpp @@ -279,4 +279,20 @@ const const_cell_iterator::reference const_cell_iterator::operator*() const { return ws_.cell(cursor_); } + +cell_iterator::reference cell_iterator::operator->() +{ + return operator*(); +} + +const cell_iterator::reference cell_iterator::operator->() const +{ + return operator*(); +} + +const const_cell_iterator::reference const_cell_iterator::operator->() const +{ + return operator*(); +} + } // namespace xlnt