AGS: Add some more std replacements needed for recent AGS code

This commit is contained in:
Thierry Crozat 2022-06-17 23:06:38 +01:00
parent 038579d0d9
commit 73ff6317fd
2 changed files with 32 additions and 0 deletions

View File

@ -125,6 +125,22 @@ ForwardIt upper_bound(ForwardIt first, ForwardIt last, const T &value, Compare c
return last;
}
template<class ForwardIt>
ForwardIt next(ForwardIt it, int n = 1) {
ForwardIt it2 = it;
while (n > 0) { ++it2; --n; }
while (n < 0) { --it2; ++n; }
return it2;
}
template<class BidirIt>
BidirIt prev(BidirIt it, int n = 1) {
BidirIt it2 = it;
while (n > 0) { --it2; --n; }
while (n < 0) { ++it2; ++n; }
return it2;
}
} // namespace std
} // namespace AGS3

View File

@ -68,6 +68,22 @@ public:
reverse_iterator rend() {
return reverse_iterator(Common::List<T>::end());
}
void splice(typename Common::List<T>::iterator pos, list<T>& /*other*/, typename Common::List<T>::iterator it ) {
// We insert it before pos in this list
typename Common::List<T>::NodeBase *n = static_cast<typename Common::List<T>::NodeBase *>(it._node);
typename Common::List<T>::NodeBase *nPos = static_cast<typename Common::List<T>::NodeBase*>(pos._node);
if (n == nPos || n->_next == nPos)
return;
// Remove from current position
n->_prev->_next = n->_next;
n->_next->_prev = n->_prev;
// Insert in new position
n->_next = nPos;
n->_prev = nPos->_prev;
n->_prev->_next = n;
n->_next->_prev = n;
}
};
} // namespace std