diff --git a/src/utils/smart_list.hpp b/src/utils/smart_list.hpp index 5ca530506cd6..e42621aaed64 100644 --- a/src/utils/smart_list.hpp +++ b/src/utils/smart_list.hpp @@ -112,7 +112,20 @@ class smart_list ~iterator_base() { unref(ptr_); } // Assignment - iterator_base & operator=(const iterator_base & that); + iterator_base & operator=(const iterator_base & that) + // NOTE: This is defined here because MSVC was unable to match the + // definition to the declaration when they were separate. + { + // Update our pointer. + node_t * old_ptr = ptr_; + ptr_ = that.ptr_; + + // Update reference counts. + refer(); + unref(old_ptr); + + return *this; + } // Comparison: bool operator==(const iterator_base & that) const { return ptr_ == that.ptr_; } @@ -125,8 +138,22 @@ class smart_list // Increment/decrement: iterator_base & operator++() { advance(Reversed); return *this; } iterator_base & operator--() { advance(!Reversed); return *this; } - iterator_base operator++(int); - iterator_base operator--(int); + iterator_base operator++(int) + // NOTE: This is defined here because MSVC was unable to match the + // definition to the declaration when they were separate. + { + iterator_base retval(*this); + advance(Reversed); + return retval; + } + iterator_base operator--(int) + // NOTE: This is defined here because MSVC was unable to match the + // definition to the declaration when they were separate. + { + iterator_base retval(*this); + advance(!Reversed); + return retval; + } /// Test for being in a list, rather than past-the-end (or unassigned). bool derefable() const { return derefable(ptr_); } @@ -744,45 +771,6 @@ inline smart_list::node_t::~node_t() /* ** smart_list::iterator_base ** */ -/** Assignment */ -template -template -inline typename smart_list::template iterator_base & - smart_list::iterator_base::operator= - (const iterator_base & that) -{ - // Update our pointer. - node_t * old_ptr = ptr_; - ptr_ = that.ptr_; - - // Update reference counts. - refer(); - unref(old_ptr); - - return *this; -} - -/** Post-increment */ -template -template -inline typename smart_list::template iterator_base - smart_list::iterator_base::operator++(int) -{ - iterator_base retval(*this); - advance(Reversed); - return retval; -} -/** Post-decrement */ -template -template -inline typename smart_list::template iterator_base - smart_list::iterator_base::operator--(int) -{ - iterator_base retval(*this); - advance(!Reversed); - return retval; -} - /** * Advances our pointer to an unflagged node, possibly in the reverse direction. * This will advance at least one step, and will not stop on a flagged node.