Add prefix inc/dec to TSLQIterWrapper

This commit is contained in:
Stephen Seo 2019-10-24 17:58:13 +09:00
parent ebedd06fdb
commit aa132fbf12

View file

@ -51,6 +51,9 @@ class TSLQueue {
bool prev(); bool prev();
std::optional<T> current(); std::optional<T> current();
TSLQIterWrapper<isConst, isRev>& operator++();
TSLQIterWrapper<isConst, isRev>& operator--();
private: private:
std::conditional_t<isConst, const std::list<T>, std::list<T>> std::conditional_t<isConst, const std::list<T>, std::list<T>>
*containerPtr; *containerPtr;
@ -333,6 +336,20 @@ std::optional<T> TSLQueue<T>::TSLQIterWrapper<isConst, isRev>::current() {
return *iter; return *iter;
} }
template <typename T>
template <bool isConst, bool isRev>
typename TSLQueue<T>::template TSLQIterWrapper<isConst, isRev>& TSLQueue<T>::TSLQIterWrapper<isConst, isRev>::operator++() {
next();
return *this;
}
template <typename T>
template <bool isConst, bool isRev>
typename TSLQueue<T>::template TSLQIterWrapper<isConst, isRev>& TSLQueue<T>::TSLQIterWrapper<isConst, isRev>::operator--() {
prev();
return *this;
}
template <typename T> template <typename T>
typename TSLQueue<T>::template TSLQIterWrapper<false, false> TSLQueue<T>::iter() { typename TSLQueue<T>::template TSLQIterWrapper<false, false> TSLQueue<T>::iter() {
return TSLQIterWrapper<false, false>(&container, iterValid, iterWrapperCount); return TSLQIterWrapper<false, false>(&container, iterValid, iterWrapperCount);