Browse Source

resource_cache: constexpr all the way (see #883)

Michele Caini 3 years ago
parent
commit
b0d69c50da
1 changed files with 24 additions and 24 deletions
  1. 24 24
      src/entt/resource/cache.hpp

+ 24 - 24
src/entt/resource/cache.hpp

@@ -39,108 +39,108 @@ public:
     using difference_type = std::ptrdiff_t;
     using difference_type = std::ptrdiff_t;
     using iterator_category = std::input_iterator_tag;
     using iterator_category = std::input_iterator_tag;
 
 
-    resource_cache_iterator() ENTT_NOEXCEPT = default;
+    constexpr resource_cache_iterator() ENTT_NOEXCEPT = default;
 
 
-    resource_cache_iterator(const It iter) ENTT_NOEXCEPT
+    constexpr resource_cache_iterator(const It iter) ENTT_NOEXCEPT
         : it{iter} {}
         : it{iter} {}
 
 
     template<typename Other, typename = std::enable_if_t<!std::is_same_v<It, Other> && std::is_constructible_v<It, Other>>>
     template<typename Other, typename = std::enable_if_t<!std::is_same_v<It, Other> && std::is_constructible_v<It, Other>>>
-    resource_cache_iterator(const resource_cache_iterator<std::remove_const_t<Type>, Other> &other) ENTT_NOEXCEPT
+    constexpr resource_cache_iterator(const resource_cache_iterator<std::remove_const_t<Type>, Other> &other) ENTT_NOEXCEPT
         : it{other.it} {}
         : it{other.it} {}
 
 
-    resource_cache_iterator &operator++() ENTT_NOEXCEPT {
+    constexpr resource_cache_iterator &operator++() ENTT_NOEXCEPT {
         return ++it, *this;
         return ++it, *this;
     }
     }
 
 
-    resource_cache_iterator operator++(int) ENTT_NOEXCEPT {
+    constexpr resource_cache_iterator operator++(int) ENTT_NOEXCEPT {
         resource_cache_iterator orig = *this;
         resource_cache_iterator orig = *this;
         return ++(*this), orig;
         return ++(*this), orig;
     }
     }
 
 
-    resource_cache_iterator &operator--() ENTT_NOEXCEPT {
+    constexpr resource_cache_iterator &operator--() ENTT_NOEXCEPT {
         return --it, *this;
         return --it, *this;
     }
     }
 
 
-    resource_cache_iterator operator--(int) ENTT_NOEXCEPT {
+    constexpr resource_cache_iterator operator--(int) ENTT_NOEXCEPT {
         resource_cache_iterator orig = *this;
         resource_cache_iterator orig = *this;
         return operator--(), orig;
         return operator--(), orig;
     }
     }
 
 
-    resource_cache_iterator &operator+=(const difference_type value) ENTT_NOEXCEPT {
+    constexpr resource_cache_iterator &operator+=(const difference_type value) ENTT_NOEXCEPT {
         it += value;
         it += value;
         return *this;
         return *this;
     }
     }
 
 
-    resource_cache_iterator operator+(const difference_type value) const ENTT_NOEXCEPT {
+    constexpr resource_cache_iterator operator+(const difference_type value) const ENTT_NOEXCEPT {
         resource_cache_iterator copy = *this;
         resource_cache_iterator copy = *this;
         return (copy += value);
         return (copy += value);
     }
     }
 
 
-    resource_cache_iterator &operator-=(const difference_type value) ENTT_NOEXCEPT {
+    constexpr resource_cache_iterator &operator-=(const difference_type value) ENTT_NOEXCEPT {
         return (*this += -value);
         return (*this += -value);
     }
     }
 
 
-    resource_cache_iterator operator-(const difference_type value) const ENTT_NOEXCEPT {
+    constexpr resource_cache_iterator operator-(const difference_type value) const ENTT_NOEXCEPT {
         return (*this + -value);
         return (*this + -value);
     }
     }
 
 
-    [[nodiscard]] reference operator[](const difference_type value) const ENTT_NOEXCEPT {
+    [[nodiscard]] constexpr reference operator[](const difference_type value) const ENTT_NOEXCEPT {
         return {it[value].first, resource<Type>{it[value].second}};
         return {it[value].first, resource<Type>{it[value].second}};
     }
     }
 
 
-    [[nodiscard]] reference operator*() const ENTT_NOEXCEPT {
+    [[nodiscard]] constexpr reference operator*() const ENTT_NOEXCEPT {
         return (*this)[0];
         return (*this)[0];
     }
     }
 
 
-    [[nodiscard]] pointer operator->() const ENTT_NOEXCEPT {
+    [[nodiscard]] constexpr pointer operator->() const ENTT_NOEXCEPT {
         return operator*();
         return operator*();
     }
     }
 
 
     template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
     template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
-    friend std::ptrdiff_t operator-(const resource_cache_iterator<TLhs, ILhs> &, const resource_cache_iterator<TRhs, IRhs> &) ENTT_NOEXCEPT;
+    friend constexpr std::ptrdiff_t operator-(const resource_cache_iterator<TLhs, ILhs> &, const resource_cache_iterator<TRhs, IRhs> &) ENTT_NOEXCEPT;
 
 
     template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
     template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
-    friend bool operator==(const resource_cache_iterator<TLhs, ILhs> &, const resource_cache_iterator<TRhs, IRhs> &) ENTT_NOEXCEPT;
+    friend constexpr bool operator==(const resource_cache_iterator<TLhs, ILhs> &, const resource_cache_iterator<TRhs, IRhs> &) ENTT_NOEXCEPT;
 
 
     template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
     template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
-    friend bool operator<(const resource_cache_iterator<TLhs, ILhs> &, const resource_cache_iterator<TRhs, IRhs> &) ENTT_NOEXCEPT;
+    friend constexpr bool operator<(const resource_cache_iterator<TLhs, ILhs> &, const resource_cache_iterator<TRhs, IRhs> &) ENTT_NOEXCEPT;
 
 
 private:
 private:
     It it;
     It it;
 };
 };
 
 
 template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
 template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
-[[nodiscard]] std::ptrdiff_t operator-(const resource_cache_iterator<TLhs, ILhs> &lhs, const resource_cache_iterator<TRhs, IRhs> &rhs) ENTT_NOEXCEPT {
+[[nodiscard]] constexpr std::ptrdiff_t operator-(const resource_cache_iterator<TLhs, ILhs> &lhs, const resource_cache_iterator<TRhs, IRhs> &rhs) ENTT_NOEXCEPT {
     return lhs.it - rhs.it;
     return lhs.it - rhs.it;
 }
 }
 
 
 template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
 template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
-[[nodiscard]] bool operator==(const resource_cache_iterator<TLhs, ILhs> &lhs, const resource_cache_iterator<TRhs, IRhs> &rhs) ENTT_NOEXCEPT {
+[[nodiscard]] constexpr bool operator==(const resource_cache_iterator<TLhs, ILhs> &lhs, const resource_cache_iterator<TRhs, IRhs> &rhs) ENTT_NOEXCEPT {
     return lhs.it == rhs.it;
     return lhs.it == rhs.it;
 }
 }
 
 
 template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
 template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
-[[nodiscard]] bool operator!=(const resource_cache_iterator<TLhs, ILhs> &lhs, const resource_cache_iterator<TRhs, IRhs> &rhs) ENTT_NOEXCEPT {
+[[nodiscard]] constexpr bool operator!=(const resource_cache_iterator<TLhs, ILhs> &lhs, const resource_cache_iterator<TRhs, IRhs> &rhs) ENTT_NOEXCEPT {
     return !(lhs == rhs);
     return !(lhs == rhs);
 }
 }
 
 
 template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
 template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
-[[nodiscard]] bool operator<(const resource_cache_iterator<TLhs, ILhs> &lhs, const resource_cache_iterator<TRhs, IRhs> &rhs) ENTT_NOEXCEPT {
+[[nodiscard]] constexpr bool operator<(const resource_cache_iterator<TLhs, ILhs> &lhs, const resource_cache_iterator<TRhs, IRhs> &rhs) ENTT_NOEXCEPT {
     return lhs.it < rhs.it;
     return lhs.it < rhs.it;
 }
 }
 
 
 template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
 template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
-[[nodiscard]] bool operator>(const resource_cache_iterator<TLhs, ILhs> &lhs, const resource_cache_iterator<TRhs, IRhs> &rhs) ENTT_NOEXCEPT {
+[[nodiscard]] constexpr bool operator>(const resource_cache_iterator<TLhs, ILhs> &lhs, const resource_cache_iterator<TRhs, IRhs> &rhs) ENTT_NOEXCEPT {
     return rhs < lhs;
     return rhs < lhs;
 }
 }
 
 
 template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
 template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
-[[nodiscard]] bool operator<=(const resource_cache_iterator<TLhs, ILhs> &lhs, const resource_cache_iterator<TRhs, IRhs> &rhs) ENTT_NOEXCEPT {
+[[nodiscard]] constexpr bool operator<=(const resource_cache_iterator<TLhs, ILhs> &lhs, const resource_cache_iterator<TRhs, IRhs> &rhs) ENTT_NOEXCEPT {
     return !(lhs > rhs);
     return !(lhs > rhs);
 }
 }
 
 
 template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
 template<typename TLhs, typename ILhs, typename TRhs, typename IRhs>
-[[nodiscard]] bool operator>=(const resource_cache_iterator<TLhs, ILhs> &lhs, const resource_cache_iterator<TRhs, IRhs> &rhs) ENTT_NOEXCEPT {
+[[nodiscard]] constexpr bool operator>=(const resource_cache_iterator<TLhs, ILhs> &lhs, const resource_cache_iterator<TRhs, IRhs> &rhs) ENTT_NOEXCEPT {
     return !(lhs < rhs);
     return !(lhs < rhs);
 }
 }