From fe66cde6168308f35520cc417d583a5b4275625a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 10 Jul 2024 20:10:52 +0200 Subject: [PATCH] util/DereferenceIterator: add `constexpr` --- src/util/DereferenceIterator.hxx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/util/DereferenceIterator.hxx b/src/util/DereferenceIterator.hxx index 6927019f3..3cc44480c 100644 --- a/src/util/DereferenceIterator.hxx +++ b/src/util/DereferenceIterator.hxx @@ -24,60 +24,60 @@ public: using pointer = VT *; using reference = VT &; - DereferenceIterator() = default; + constexpr DereferenceIterator() = default; constexpr DereferenceIterator(const IT _original) noexcept :original(_original) {} - reference operator*() const noexcept { + constexpr reference operator*() const noexcept { return static_cast(**original); } - pointer operator->() const noexcept { + constexpr pointer operator->() const noexcept { return static_cast(&**original); } - auto &operator++() noexcept { + constexpr auto &operator++() noexcept { ++original; return *this; } - auto operator++(int) noexcept { + constexpr auto operator++(int) noexcept { auto old = *this; original++; return old; } - auto &operator+=(difference_type n) noexcept { + constexpr auto &operator+=(difference_type n) noexcept { original += n; return *this; } - auto &operator+(difference_type n) const noexcept { + constexpr auto &operator+(difference_type n) const noexcept { return original + n; } - auto &operator--() noexcept { + constexpr auto &operator--() noexcept { original = --original; return *this; } - auto operator--(int) noexcept { + constexpr auto operator--(int) noexcept { auto old = *this; original--; return old; } - auto &operator-=(difference_type n) noexcept { + constexpr auto &operator-=(difference_type n) noexcept { original -= n; return *this; } - auto &operator-(difference_type n) const noexcept { + constexpr auto &operator-(difference_type n) const noexcept { return original - n; } - bool operator==(const DereferenceIterator &other) const noexcept { + constexpr bool operator==(const DereferenceIterator &other) const noexcept { return original == other.original; } };