diff options
| -rw-r--r-- | libs/kstd/kstd/ring_buffer.hpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libs/kstd/kstd/ring_buffer.hpp b/libs/kstd/kstd/ring_buffer.hpp index 075701ee..d8873b2c 100644 --- a/libs/kstd/kstd/ring_buffer.hpp +++ b/libs/kstd/kstd/ring_buffer.hpp @@ -137,9 +137,8 @@ namespace kstd //! @return A pointer to the object at given position. constexpr auto element_at(size_type position) noexcept -> pointer { - auto base_pointer = reinterpret_cast<pointer>(m_storage.data()); auto storage_index = (m_read_index + position) % capacity(); - return base_pointer + storage_index; + return &m_storage[storage_index].value; } //! Get a pointer to the element at the given read-index relative position. @@ -148,7 +147,8 @@ namespace kstd //! @return A pointer to the object at given position. constexpr auto element_at(size_type position) const noexcept -> const_pointer { - return const_cast<ring_buffer *>(this)->element_at_index(position); + auto storage_index = (m_read_index + position) % capacity(); + return &m_storage[storage_index].value; } //! Trigger a kernel panic if an attempt is made to use an invalid index. |
