util/DereferenceIterator: add `constexpr`

This commit is contained in:
Max Kellermann 2024-07-10 20:10:52 +02:00
parent 0cc9ef0aee
commit fe66cde616
1 changed files with 12 additions and 12 deletions

View File

@ -24,60 +24,60 @@ public:
using pointer = VT *; using pointer = VT *;
using reference = VT &; using reference = VT &;
DereferenceIterator() = default; constexpr DereferenceIterator() = default;
constexpr DereferenceIterator(const IT _original) noexcept constexpr DereferenceIterator(const IT _original) noexcept
:original(_original) {} :original(_original) {}
reference operator*() const noexcept { constexpr reference operator*() const noexcept {
return static_cast<reference>(**original); return static_cast<reference>(**original);
} }
pointer operator->() const noexcept { constexpr pointer operator->() const noexcept {
return static_cast<pointer>(&**original); return static_cast<pointer>(&**original);
} }
auto &operator++() noexcept { constexpr auto &operator++() noexcept {
++original; ++original;
return *this; return *this;
} }
auto operator++(int) noexcept { constexpr auto operator++(int) noexcept {
auto old = *this; auto old = *this;
original++; original++;
return old; return old;
} }
auto &operator+=(difference_type n) noexcept { constexpr auto &operator+=(difference_type n) noexcept {
original += n; original += n;
return *this; return *this;
} }
auto &operator+(difference_type n) const noexcept { constexpr auto &operator+(difference_type n) const noexcept {
return original + n; return original + n;
} }
auto &operator--() noexcept { constexpr auto &operator--() noexcept {
original = --original; original = --original;
return *this; return *this;
} }
auto operator--(int) noexcept { constexpr auto operator--(int) noexcept {
auto old = *this; auto old = *this;
original--; original--;
return old; return old;
} }
auto &operator-=(difference_type n) noexcept { constexpr auto &operator-=(difference_type n) noexcept {
original -= n; original -= n;
return *this; return *this;
} }
auto &operator-(difference_type n) const noexcept { constexpr auto &operator-(difference_type n) const noexcept {
return original - n; return original - n;
} }
bool operator==(const DereferenceIterator<IT,VT> &other) const noexcept { constexpr bool operator==(const DereferenceIterator<IT,VT> &other) const noexcept {
return original == other.original; return original == other.original;
} }
}; };