diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-07-01 13:38:58 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-01 22:44:06 +0200 |
commit | 59ba316ac6e6315c3142e95916f977e8fe8655a7 (patch) | |
tree | a5f60fe65eb5e35870d45f4e4da49e733faf40e7 | |
parent | 60efe18a3162c90a519d845e83a2f78181b9b3ef (diff) | |
download | serenity-59ba316ac6e6315c3142e95916f977e8fe8655a7.zip |
AK: Annotate more AK::Span methods as nodiscard
-rw-r--r-- | AK/Span.h | 30 |
1 files changed, 16 insertions, 14 deletions
@@ -99,11 +99,11 @@ public: { } - ALWAYS_INLINE constexpr const T* data() const { return this->m_values; } - ALWAYS_INLINE constexpr T* data() { return this->m_values; } + [[nodiscard]] ALWAYS_INLINE constexpr const T* data() const { return this->m_values; } + [[nodiscard]] ALWAYS_INLINE constexpr T* data() { return this->m_values; } - ALWAYS_INLINE constexpr const T* offset_pointer(size_t offset) const { return this->m_values + offset; } - ALWAYS_INLINE constexpr T* offset_pointer(size_t offset) { return this->m_values + offset; } + [[nodiscard]] ALWAYS_INLINE constexpr const T* offset_pointer(size_t offset) const { return this->m_values + offset; } + [[nodiscard]] ALWAYS_INLINE constexpr T* offset_pointer(size_t offset) { return this->m_values + offset; } using ConstIterator = SimpleIterator<const Span, const T>; using Iterator = SimpleIterator<Span, T>; @@ -114,9 +114,9 @@ public: constexpr ConstIterator end() const { return ConstIterator::end(*this); } constexpr Iterator end() { return Iterator::end(*this); } - ALWAYS_INLINE constexpr size_t size() const { return this->m_size; } - ALWAYS_INLINE constexpr bool is_null() const { return this->m_values == nullptr; } - ALWAYS_INLINE constexpr bool is_empty() const { return this->m_size == 0; } + [[nodiscard]] ALWAYS_INLINE constexpr size_t size() const { return this->m_size; } + [[nodiscard]] ALWAYS_INLINE constexpr bool is_null() const { return this->m_values == nullptr; } + [[nodiscard]] ALWAYS_INLINE constexpr bool is_empty() const { return this->m_size == 0; } [[nodiscard]] ALWAYS_INLINE constexpr Span slice(size_t start, size_t length) const { @@ -139,7 +139,7 @@ public: return { this->m_values, min(size(), length) }; } - ALWAYS_INLINE constexpr T* offset(size_t start) const + [[nodiscard]] ALWAYS_INLINE constexpr T* offset(size_t start) const { VERIFY(start < this->m_size); return this->m_values + start; @@ -172,7 +172,7 @@ public: return size(); } - bool constexpr contains_slow(const T& value) const + [[nodiscard]] bool constexpr contains_slow(const T& value) const { for (size_t i = 0; i < size(); ++i) { if (at(i) == value) @@ -181,7 +181,7 @@ public: return false; } - bool constexpr starts_with(Span<const T> other) const + [[nodiscard]] bool constexpr starts_with(Span<const T> other) const { if (size() < other.size()) return false; @@ -189,22 +189,24 @@ public: return TypedTransfer<T>::compare(data(), other.data(), other.size()); } - ALWAYS_INLINE constexpr const T& at(size_t index) const + [[nodiscard]] ALWAYS_INLINE constexpr const T& at(size_t index) const { VERIFY(index < this->m_size); return this->m_values[index]; } - ALWAYS_INLINE constexpr T& at(size_t index) + + [[nodiscard]] ALWAYS_INLINE constexpr T& at(size_t index) { VERIFY(index < this->m_size); return this->m_values[index]; } - ALWAYS_INLINE constexpr const T& operator[](size_t index) const + [[nodiscard]] ALWAYS_INLINE constexpr const T& operator[](size_t index) const { return at(index); } - ALWAYS_INLINE constexpr T& operator[](size_t index) + + [[nodiscard]] ALWAYS_INLINE constexpr T& operator[](size_t index) { return at(index); } |