From 2169d24714147114f686e4e4dfa6ea19437de3b3 Mon Sep 17 00:00:00 2001 From: Crzyrndm Date: Thu, 31 May 2018 15:37:10 +1200 Subject: [PATCH] range_iterator - operator* const overloads Users may still want to dereference a const iterator (note: not a const_iterator). Also use the "reference" typedef to ensure there is only 1 source of information --- include/xlnt/worksheet/range_iterator.hpp | 9 +++++++-- source/worksheet/range_iterator.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/xlnt/worksheet/range_iterator.hpp b/include/xlnt/worksheet/range_iterator.hpp index 5e942f73..c6f43979 100644 --- a/include/xlnt/worksheet/range_iterator.hpp +++ b/include/xlnt/worksheet/range_iterator.hpp @@ -86,7 +86,12 @@ public: /// /// Dereference the iterator to return a column or row. /// - cell_vector operator*() const; + reference operator*(); + + /// + /// Dereference the iterator to return a column or row. + /// + const reference operator*() const; /// /// Returns true if this iterator is equivalent to other. @@ -196,7 +201,7 @@ public: /// /// Dereferennce the iterator to return the current column/row. /// - const cell_vector operator*() const; + const reference operator*() const; /// /// Returns true if this iterator is equivalent to other. diff --git a/source/worksheet/range_iterator.cpp b/source/worksheet/range_iterator.cpp index 57208d26..2c7a3a10 100644 --- a/source/worksheet/range_iterator.cpp +++ b/source/worksheet/range_iterator.cpp @@ -28,7 +28,12 @@ namespace xlnt { -cell_vector range_iterator::operator*() const +range_iterator::reference range_iterator::operator*() +{ + return cell_vector(ws_, cursor_, bounds_, order_, skip_null_, false); +} + +const range_iterator::reference range_iterator::operator*() const { return cell_vector(ws_, cursor_, bounds_, order_, skip_null_, false); } @@ -264,7 +269,7 @@ const_range_iterator const_range_iterator::operator++(int) return old; } -const cell_vector const_range_iterator::operator*() const +const const_range_iterator::reference const_range_iterator::operator*() const { return cell_vector(ws_, cursor_, bounds_, order_, skip_null_, false); }