diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-09-30 16:56:09 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-09-30 18:00:04 +0200 |
| commit | 7b2945dd452257ffae1c122828a4734c9075a756 (patch) | |
| tree | df4d8c5f0c02ffa280012d1ad7c936e67d7dc638 | |
| parent | ee803577187b05d54026b48a2ae83f4ba6f8202a (diff) | |
| download | kernel-7b2945dd452257ffae1c122828a4734c9075a756.tar.xz kernel-7b2945dd452257ffae1c122828a4734c9075a756.zip | |
kstd: ring_buffer: add missing documentation
| -rw-r--r-- | libs/kstd/kstd/ring_buffer.hpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libs/kstd/kstd/ring_buffer.hpp b/libs/kstd/kstd/ring_buffer.hpp index 6bdfce92..6a152731 100644 --- a/libs/kstd/kstd/ring_buffer.hpp +++ b/libs/kstd/kstd/ring_buffer.hpp @@ -94,18 +94,27 @@ namespace kstd //! @} private: - constexpr auto element_at_index(size_type index) noexcept -> pointer + //! Get a pointer to the element at the given read-index relative position. + //! + //! @param position The logical (read-index relative) index of the element. + //! @return A pointer to the object at given position. + constexpr auto element_at_index(size_type position) noexcept -> pointer { auto base_pointer = reinterpret_cast<pointer>(m_storage.data()); - auto storage_index = (m_read_index + index) % capacity(); + auto storage_index = (m_read_index + position) % capacity(); return base_pointer + storage_index; } - constexpr auto element_at_index(size_type index) const noexcept -> const_pointer + //! Get a pointer to the element at the given read-index relative position. + //! + //! @param position The logical (read-index relative) index of the element. + //! @return A pointer to the object at given position. + constexpr auto element_at_index(size_type position) const noexcept -> const_pointer { - return const_cast<ring_buffer *>(this)->element_at_index(index); + return const_cast<ring_buffer *>(this)->element_at_index(position); } + //! Trigger a kernel panic if an attempt is made to use an invalid index. constexpr auto panic_on_invalid_index(size_type index) const -> void { if (index >= size()) |
