From 89e44f20c813b8731cc2f4a8502643127afcca03 Mon Sep 17 00:00:00 2001 From: Crzyrndm Date: Thu, 31 May 2018 15:27:20 +1200 Subject: [PATCH] range_iterator - rule of 5/0 For rule of 5/0, where no implementation is required, all 5 operations have been declared as defaulted. This is less likely to forget definitions for all 5 if required - removed forwarding of copy ctor to assignment (which was defaulted already) in favour of defaulted copy ctor - added defaulted move assignment/ctor and destructor --- include/xlnt/worksheet/range_iterator.hpp | 58 +++++++++++++++++------ source/worksheet/range_iterator.cpp | 10 ---- 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/include/xlnt/worksheet/range_iterator.hpp b/include/xlnt/worksheet/range_iterator.hpp index 351e257f..5e942f73 100644 --- a/include/xlnt/worksheet/range_iterator.hpp +++ b/include/xlnt/worksheet/range_iterator.hpp @@ -59,20 +59,35 @@ public: const range_reference &bounds, major_order order, bool skip_null); /// - /// Copy constructor. + /// Default copy constructor. /// - range_iterator(const range_iterator &other); - - /// - /// Dereference the iterator to return a column or row. - /// - cell_vector operator*() const; + range_iterator(const range_iterator &) = default; /// /// Default assignment operator. /// range_iterator &operator=(const range_iterator &) = default; + /// + /// Default move constructor. + /// + range_iterator(range_iterator &&) = default; + + /// + /// Default move assignment operator. + /// + range_iterator &operator=(range_iterator &&) = default; + + /// + /// Default destructor + /// + ~range_iterator() = default; + + /// + /// Dereference the iterator to return a column or row. + /// + cell_vector operator*() const; + /// /// Returns true if this iterator is equivalent to other. /// @@ -154,20 +169,35 @@ public: const range_reference &bounds, major_order order, bool skip_null); /// - /// Copy constructor. + /// Default copy constructor. /// - const_range_iterator(const const_range_iterator &other); - - /// - /// Dereferennce the iterator to return the current column/row. - /// - const cell_vector operator*() const; + const_range_iterator(const const_range_iterator &) = default; /// /// Default assignment operator. /// const_range_iterator &operator=(const const_range_iterator &) = default; + /// + /// Default move constructor. + /// + const_range_iterator(const_range_iterator &&) = default; + + /// + /// Default move assignment operator. + /// + const_range_iterator &operator=(const_range_iterator &&) = default; + + /// + /// Default destructor + /// + ~const_range_iterator() = default; + + /// + /// Dereferennce the iterator to return the current column/row. + /// + const cell_vector 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 2da73d5c..57208d26 100644 --- a/source/worksheet/range_iterator.cpp +++ b/source/worksheet/range_iterator.cpp @@ -47,11 +47,6 @@ range_iterator::range_iterator(worksheet &ws, const cell_reference &cursor, } } -range_iterator::range_iterator(const range_iterator &other) -{ - *this = other; -} - bool range_iterator::operator==(const range_iterator &other) const { return ws_ == other.ws_ @@ -168,11 +163,6 @@ const_range_iterator::const_range_iterator(const worksheet &ws, const cell_refer } } -const_range_iterator::const_range_iterator(const const_range_iterator &other) -{ - *this = other; -} - bool const_range_iterator::operator==(const const_range_iterator &other) const { return ws_ == other.ws_