2024-08-31 20:34:49 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: auReverseIterator.ipp
|
|
|
|
Date: 2024-08-31
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
template<typename Iterator>
|
2024-09-01 18:43:22 +00:00
|
|
|
constexpr AuReverseIterator<Iterator>::AuReverseIterator(Iterator that) :
|
|
|
|
iterator(AuMove(that))
|
2024-08-31 20:34:49 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
template<typename Other_t>
|
|
|
|
constexpr AuReverseIterator<Iterator>::AuReverseIterator(const AuReverseIterator<Other_t> &that) :
|
|
|
|
iterator(that.iterator)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
template<class Other_t>
|
|
|
|
constexpr AuReverseIterator<Iterator> &AuReverseIterator<Iterator>::operator=(const AuReverseIterator<Other_t> &that)
|
|
|
|
{
|
|
|
|
iterator = that.iterator;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
constexpr Iterator AuReverseIterator<Iterator>::base() const
|
|
|
|
{
|
|
|
|
return iterator;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
constexpr Iterator AuReverseIterator<Iterator>::Base() const
|
|
|
|
{
|
|
|
|
return iterator;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
constexpr AuReverseIterator<Iterator>::reference AuReverseIterator<Iterator>::operator*() const
|
|
|
|
{
|
|
|
|
Iterator ret = iterator;
|
|
|
|
return *--ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
constexpr AuReverseIterator<Iterator>::pointer AuReverseIterator<Iterator>::operator->() const
|
|
|
|
{
|
|
|
|
Iterator ret = iterator;
|
|
|
|
--ret;
|
|
|
|
if constexpr (AuIsPointer_v<Iterator>)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret.operator->();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
constexpr AuReverseIterator<Iterator> &AuReverseIterator<Iterator>::operator++()
|
|
|
|
{
|
|
|
|
--iterator;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
constexpr AuReverseIterator<Iterator> AuReverseIterator<Iterator>::operator++(int)
|
|
|
|
{
|
|
|
|
AuReverseIterator ret = *this;
|
|
|
|
--iterator;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
constexpr AuReverseIterator<Iterator> &AuReverseIterator<Iterator>::operator--()
|
|
|
|
{
|
|
|
|
++iterator;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
constexpr AuReverseIterator<Iterator> AuReverseIterator<Iterator>::operator--(int)
|
|
|
|
{
|
|
|
|
AuReverseIterator ret = *this;
|
|
|
|
++iterator;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
constexpr AuReverseIterator<Iterator> AuReverseIterator<Iterator>::operator+(const difference_type offset) const
|
|
|
|
{
|
|
|
|
return AuReverseIterator(iterator - offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
constexpr AuReverseIterator<Iterator> &AuReverseIterator<Iterator>::operator+=(const difference_type offset)
|
|
|
|
{
|
|
|
|
iterator -= offset;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
constexpr AuReverseIterator<Iterator> AuReverseIterator<Iterator>::operator-(const difference_type offset) const
|
|
|
|
{
|
|
|
|
return AuReverseIterator(iterator + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
constexpr AuReverseIterator<Iterator> &AuReverseIterator<Iterator>::operator-=(const difference_type offset)
|
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Iterator>
|
|
|
|
constexpr AuReverseIterator<Iterator>::reference AuReverseIterator<Iterator>::operator[](const difference_type offset) const
|
|
|
|
{
|
|
|
|
return iterator[static_cast<difference_type>(-offset - 1)];
|
|
|
|
}
|