diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-10-05 13:04:37 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-10-05 13:04:37 +0200 |
| commit | 3bc20030f591acb0e23311964bcd576614caf268 (patch) | |
| tree | 45dd88ed4a309bac1907b1363449b804a7cc1ae9 | |
| parent | a4fe8ea88e8ce6f1a211598894e6157bab86a369 (diff) | |
| download | kernel-3bc20030f591acb0e23311964bcd576614caf268.tar.xz kernel-3bc20030f591acb0e23311964bcd576614caf268.zip | |
kstd: ring_buffer: add missing noexcept specifications
| -rw-r--r-- | libs/kstd/kstd/ring_buffer.hpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/libs/kstd/kstd/ring_buffer.hpp b/libs/kstd/kstd/ring_buffer.hpp index 2f6a6b9f..8176b68b 100644 --- a/libs/kstd/kstd/ring_buffer.hpp +++ b/libs/kstd/kstd/ring_buffer.hpp @@ -263,7 +263,7 @@ namespace kstd constexpr ring_buffer() noexcept = default; //! Construct a ring buffer by copying from an existing one. - constexpr ring_buffer(ring_buffer const & other) + constexpr ring_buffer(ring_buffer const & other) noexcept(std::is_nothrow_copy_constructible_v<ValueType>) : m_size{other.m_size} , m_read_index{} { @@ -272,7 +272,8 @@ namespace kstd } //! Construct a ring buffer by moving from an existing one. - constexpr ring_buffer(ring_buffer && other) + constexpr ring_buffer(ring_buffer && other) noexcept(std::is_nothrow_move_constructible_v<ValueType> && + std::is_nothrow_destructible_v<ValueType>) : m_size{other.m_size} , m_read_index{} { @@ -284,7 +285,7 @@ namespace kstd } //! Destroy this ring buffer. - constexpr ~ring_buffer() noexcept + constexpr ~ring_buffer() noexcept(std::is_nothrow_destructible_v<ValueType>) { clear(); } @@ -362,7 +363,10 @@ namespace kstd //! Replace the content of this ring buffer with a copy of the content of another one. //! //! @param other The ring buffer to copy from. - constexpr auto operator=(ring_buffer const & other) -> ring_buffer & + constexpr auto operator=(ring_buffer const & other) noexcept(std::is_nothrow_copy_constructible_v<ValueType> && + std::is_nothrow_copy_assignable_v<ValueType> && + std::is_nothrow_destructible_v<ValueType>) + -> ring_buffer & { if (this == &other) { @@ -390,7 +394,9 @@ namespace kstd //! Replace the content of this ring buffer by moving from another one. //! //! @param other The ring buffer to move from. - constexpr auto operator=(ring_buffer && other) -> ring_buffer & + constexpr auto operator=(ring_buffer && other) noexcept(std::is_nothrow_move_constructible_v<ValueType> && + std::is_nothrow_move_assignable_v<ValueType> && + std::is_nothrow_destructible_v<ValueType>) -> ring_buffer & { if (this == &other) { @@ -682,7 +688,7 @@ namespace kstd //! @name Modifiers //! @{ - constexpr auto clear() noexcept -> void + constexpr auto clear() noexcept(std::is_nothrow_destructible_v<ValueType>) -> void { std::ranges::for_each(std::views::reverse(*this), [](auto & element) { std::destroy_at(&element); }); m_size = 0; @@ -695,7 +701,8 @@ namespace kstd //! @param args The arguments to forward to the constructor of the element. template<typename... Args> requires(Capacity > 0) - constexpr auto emplace_back(Args &&... args) -> reference + constexpr auto emplace_back(Args &&... args) noexcept(std::is_nothrow_constructible_v<ValueType, Args &&...>) + -> reference { if (m_size < capacity()) { @@ -714,7 +721,8 @@ namespace kstd //! If the buffer is full, the oldest element will be overwritten. //! //! @param value The value to add to the end of this ring buffer. - constexpr auto push_back(value_type const & value) -> void + constexpr auto push_back(value_type const & value) noexcept(std::is_nothrow_copy_constructible_v<ValueType> && + std::is_nothrow_copy_assignable_v<ValueType>) -> void requires(Capacity > 0) { if (m_size < capacity()) @@ -734,7 +742,8 @@ namespace kstd //! assignment will be performed. //! //! @param value The value to add to the end of this ring buffer. - constexpr auto push_back(value_type && value) -> void + constexpr auto push_back(value_type && value) noexcept(std::is_nothrow_move_constructible_v<ValueType> && + std::is_nothrow_move_assignable_v<ValueType>) -> void requires(Capacity > 0) { if (m_size < capacity()) |
