diff --git a/src/libCom/cppStd/epicsList.h b/src/libCom/cppStd/epicsList.h index 8e3d51c38..c139dcd1f 100644 --- a/src/libCom/cppStd/epicsList.h +++ b/src/libCom/cppStd/epicsList.h @@ -6,7 +6,6 @@ #define __EPICS_LIST_H__ #include "epicsListBase.h" -#include "epicsExcept.h" #include // epicsList @@ -59,7 +58,7 @@ public: iterator insert(iterator position, const T x); iterator erase(iterator position); - iterator erase(iterator position, iterator last); + iterator erase(iterator position, iterator leave); void swap(epicsList& x); void clear(); @@ -85,8 +84,13 @@ friend class epicsListConstIterator; template inline void swap(epicsList& x, epicsList& y) { x.swap(y); } +template + inline void epicsSwap(epicsList& x, epicsList& y) { x.swap(y); } + // Mutable iterator +// These used to be inner classes of epicsList, but MSVC6 +// didn't like that so they had to be typedefs... template class epicsListIterator { @@ -281,8 +285,8 @@ inline epicsList::iterator epicsList::erase(iterator pos) { } template -inline epicsList::iterator epicsList::erase(iterator pos, iterator last) { - while (pos != last) { +inline epicsList::iterator epicsList::erase(iterator pos, iterator leave) { + while (pos != leave) { pos = erase(pos); } return pos; @@ -292,9 +296,7 @@ template inline void epicsList::swap(epicsList& x) { _head.swap(x._head); _pool.swap(x._pool); - size_type temp = x._count; - x._count = _count; - _count = temp; + epicsSwap(x._count, _count); } template diff --git a/src/libCom/cppStd/epicsListBase.h b/src/libCom/cppStd/epicsListBase.h index 99a6c4cda..bb1d00b9f 100644 --- a/src/libCom/cppStd/epicsListBase.h +++ b/src/libCom/cppStd/epicsListBase.h @@ -10,6 +10,7 @@ #endif #include "epicsMutex.h" +#include "epicsAlgorithm.h" // epicsListNode class epicsListNode { @@ -127,9 +128,7 @@ inline epicsListLink* epicsListLink::extract() { } inline void epicsListLink::swap(epicsListLink& node) { - epicsListLink* tn = node._next; - node._next = _next; - _next = tn; + epicsSwap(node._next, _next); } @@ -185,14 +184,11 @@ inline void epicsListNode::unlink() { } inline void epicsListNode::swap(epicsListNode& node) { - epicsListNode* temp = node._next; - node._next = _next; - _next = temp; + epicsSwap(node._next, _next); _next->_prev = this; node._next->_prev = &node; - temp = node._prev; - node._prev = _prev; - _prev = temp; + + epicsSwap(node._prev, _prev); _prev->_next = this; node._prev->_next = &node; }