|
|
@@ -22,9 +22,9 @@ namespace entt {
|
|
|
/*! @cond TURN_OFF_DOXYGEN */
|
|
|
namespace internal {
|
|
|
|
|
|
-template<typename Container, std::size_t Size>
|
|
|
+template<typename Container>
|
|
|
class storage_iterator final {
|
|
|
- friend storage_iterator<const Container, Size>;
|
|
|
+ friend storage_iterator<const Container>;
|
|
|
|
|
|
using container_type = std::remove_const_t<Container>;
|
|
|
using alloc_traits = std::allocator_traits<typename container_type::allocator_type>;
|
|
|
@@ -48,7 +48,7 @@ public:
|
|
|
offset{idx} {}
|
|
|
|
|
|
template<bool Const = std::is_const_v<Container>, typename = std::enable_if_t<Const>>
|
|
|
- constexpr storage_iterator(const storage_iterator<std::remove_const_t<Container>, Size> &other) noexcept
|
|
|
+ constexpr storage_iterator(const storage_iterator<std::remove_const_t<Container>> &other) noexcept
|
|
|
: storage_iterator{other.payload, other.offset} {}
|
|
|
|
|
|
constexpr storage_iterator &operator++() noexcept {
|
|
|
@@ -89,12 +89,14 @@ public:
|
|
|
|
|
|
[[nodiscard]] constexpr reference operator[](const difference_type value) const noexcept {
|
|
|
const auto pos = index() - value;
|
|
|
- return (*payload)[pos / Size][fast_mod(pos, Size)];
|
|
|
+ constexpr auto page_size = component_traits<typename Container::value_type>::page_size;
|
|
|
+ return (*payload)[pos / page_size][fast_mod(pos, page_size)];
|
|
|
}
|
|
|
|
|
|
[[nodiscard]] constexpr pointer operator->() const noexcept {
|
|
|
const auto pos = index();
|
|
|
- return (*payload)[pos / Size] + fast_mod(pos, Size);
|
|
|
+ constexpr auto page_size = component_traits<typename Container::value_type>::page_size;
|
|
|
+ return (*payload)[pos / page_size] + fast_mod(pos, page_size);
|
|
|
}
|
|
|
|
|
|
[[nodiscard]] constexpr reference operator*() const noexcept {
|
|
|
@@ -110,38 +112,38 @@ private:
|
|
|
difference_type offset;
|
|
|
};
|
|
|
|
|
|
-template<typename Lhs, typename Rhs, std::size_t Size>
|
|
|
-[[nodiscard]] constexpr std::ptrdiff_t operator-(const storage_iterator<Lhs, Size> &lhs, const storage_iterator<Rhs, Size> &rhs) noexcept {
|
|
|
+template<typename Lhs, typename Rhs>
|
|
|
+[[nodiscard]] constexpr std::ptrdiff_t operator-(const storage_iterator<Lhs> &lhs, const storage_iterator<Rhs> &rhs) noexcept {
|
|
|
return rhs.index() - lhs.index();
|
|
|
}
|
|
|
|
|
|
-template<typename Lhs, typename Rhs, std::size_t Size>
|
|
|
-[[nodiscard]] constexpr bool operator==(const storage_iterator<Lhs, Size> &lhs, const storage_iterator<Rhs, Size> &rhs) noexcept {
|
|
|
+template<typename Lhs, typename Rhs>
|
|
|
+[[nodiscard]] constexpr bool operator==(const storage_iterator<Lhs> &lhs, const storage_iterator<Rhs> &rhs) noexcept {
|
|
|
return lhs.index() == rhs.index();
|
|
|
}
|
|
|
|
|
|
-template<typename Lhs, typename Rhs, std::size_t Size>
|
|
|
-[[nodiscard]] constexpr bool operator!=(const storage_iterator<Lhs, Size> &lhs, const storage_iterator<Rhs, Size> &rhs) noexcept {
|
|
|
+template<typename Lhs, typename Rhs>
|
|
|
+[[nodiscard]] constexpr bool operator!=(const storage_iterator<Lhs> &lhs, const storage_iterator<Rhs> &rhs) noexcept {
|
|
|
return !(lhs == rhs);
|
|
|
}
|
|
|
|
|
|
-template<typename Lhs, typename Rhs, std::size_t Size>
|
|
|
-[[nodiscard]] constexpr bool operator<(const storage_iterator<Lhs, Size> &lhs, const storage_iterator<Rhs, Size> &rhs) noexcept {
|
|
|
+template<typename Lhs, typename Rhs>
|
|
|
+[[nodiscard]] constexpr bool operator<(const storage_iterator<Lhs> &lhs, const storage_iterator<Rhs> &rhs) noexcept {
|
|
|
return lhs.index() > rhs.index();
|
|
|
}
|
|
|
|
|
|
-template<typename Lhs, typename Rhs, std::size_t Size>
|
|
|
-[[nodiscard]] constexpr bool operator>(const storage_iterator<Lhs, Size> &lhs, const storage_iterator<Rhs, Size> &rhs) noexcept {
|
|
|
+template<typename Lhs, typename Rhs>
|
|
|
+[[nodiscard]] constexpr bool operator>(const storage_iterator<Lhs> &lhs, const storage_iterator<Rhs> &rhs) noexcept {
|
|
|
return rhs < lhs;
|
|
|
}
|
|
|
|
|
|
-template<typename Lhs, typename Rhs, std::size_t Size>
|
|
|
-[[nodiscard]] constexpr bool operator<=(const storage_iterator<Lhs, Size> &lhs, const storage_iterator<Rhs, Size> &rhs) noexcept {
|
|
|
+template<typename Lhs, typename Rhs>
|
|
|
+[[nodiscard]] constexpr bool operator<=(const storage_iterator<Lhs> &lhs, const storage_iterator<Rhs> &rhs) noexcept {
|
|
|
return !(lhs > rhs);
|
|
|
}
|
|
|
|
|
|
-template<typename Lhs, typename Rhs, std::size_t Size>
|
|
|
-[[nodiscard]] constexpr bool operator>=(const storage_iterator<Lhs, Size> &lhs, const storage_iterator<Rhs, Size> &rhs) noexcept {
|
|
|
+template<typename Lhs, typename Rhs>
|
|
|
+[[nodiscard]] constexpr bool operator>=(const storage_iterator<Lhs> &lhs, const storage_iterator<Rhs> &rhs) noexcept {
|
|
|
return !(lhs < rhs);
|
|
|
}
|
|
|
|
|
|
@@ -405,9 +407,9 @@ public:
|
|
|
/*! @brief Constant pointer type to contained elements. */
|
|
|
using const_pointer = typename alloc_traits::template rebind_traits<typename alloc_traits::const_pointer>::const_pointer;
|
|
|
/*! @brief Random access iterator type. */
|
|
|
- using iterator = internal::storage_iterator<container_type, traits_type::page_size>;
|
|
|
+ using iterator = internal::storage_iterator<container_type>;
|
|
|
/*! @brief Constant random access iterator type. */
|
|
|
- using const_iterator = internal::storage_iterator<const container_type, traits_type::page_size>;
|
|
|
+ using const_iterator = internal::storage_iterator<const container_type>;
|
|
|
/*! @brief Reverse iterator type. */
|
|
|
using reverse_iterator = std::reverse_iterator<iterator>;
|
|
|
/*! @brief Constant reverse iterator type. */
|