diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-03-16 14:37:17 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-03-16 14:37:17 +0100 |
| commit | cc5f6ef95acb7a0024c43eba314eb1f3563b41b8 (patch) | |
| tree | f221c99d19aed64d605c0b07db8a20178747bd67 | |
| parent | b014f1cd12262afee9933d7c07d61242edc28a95 (diff) | |
| download | teachos-cc5f6ef95acb7a0024c43eba314eb1f3563b41b8.tar.xz teachos-cc5f6ef95acb7a0024c43eba314eb1f3563b41b8.zip | |
kstd: fix lint issues
| -rw-r--r-- | libs/kstd/include/kstd/bits/shared_ptr.hpp | 5 | ||||
| -rw-r--r-- | libs/kstd/include/kstd/bits/unique_ptr.hpp | 4 | ||||
| -rw-r--r-- | libs/kstd/include/kstd/vector | 34 |
3 files changed, 24 insertions, 19 deletions
diff --git a/libs/kstd/include/kstd/bits/shared_ptr.hpp b/libs/kstd/include/kstd/bits/shared_ptr.hpp index c57fa46..cfe5d18 100644 --- a/libs/kstd/include/kstd/bits/shared_ptr.hpp +++ b/libs/kstd/include/kstd/bits/shared_ptr.hpp @@ -3,6 +3,9 @@ #include <atomic> #include <cstddef> +#include <utility> + +// IWYU pragma: private, include <kstd/memory> namespace kstd { @@ -180,7 +183,7 @@ namespace kstd * @return The number of Shared_pointer instances managing the current object or 0 if there is no managed * object. */ - auto use_count() const -> std::size_t + [[nodiscard]] auto use_count() const -> std::size_t { if (pointer != nullptr) { diff --git a/libs/kstd/include/kstd/bits/unique_ptr.hpp b/libs/kstd/include/kstd/bits/unique_ptr.hpp index f9a5a34..e0870b1 100644 --- a/libs/kstd/include/kstd/bits/unique_ptr.hpp +++ b/libs/kstd/include/kstd/bits/unique_ptr.hpp @@ -3,6 +3,8 @@ #include <utility> +// IWYU pragma: private, include <kstd/memory> + namespace kstd { /** @@ -96,7 +98,7 @@ namespace kstd * * @return Pointer to the managed object or nullptr if no object is owned. */ - auto get() const -> T * + [[nodiscard]] auto get() const -> T * { return pointer; } diff --git a/libs/kstd/include/kstd/vector b/libs/kstd/include/kstd/vector index e0edf6a..7568cb6 100644 --- a/libs/kstd/include/kstd/vector +++ b/libs/kstd/include/kstd/vector @@ -123,7 +123,7 @@ namespace kstd * * @return Current amount of elements. */ - auto size() const -> size_type + [[nodiscard]] auto size() const -> size_type { return _size; } @@ -134,7 +134,7 @@ namespace kstd * * @return Current amount of space the vector has for elements. */ - auto capacity() const -> size_type + [[nodiscard]] auto capacity() const -> size_type { return _capacity; } @@ -187,7 +187,7 @@ namespace kstd * @param index Index we want to access elements at. * @return Reference to the underlying element. */ - auto at(size_type index) const -> const_reference + [[nodiscard]] auto at(size_type index) const -> const_reference { throw_if_out_of_range(index); return this->operator[](index); @@ -263,7 +263,7 @@ namespace kstd * * @return Iterator to the first element. */ - auto begin() const noexcept -> const_pointer + [[nodiscard]] auto begin() const noexcept -> const_pointer { return _data; } @@ -274,7 +274,7 @@ namespace kstd * * @return Iterator to the first element. */ - auto cbegin() const noexcept -> const_pointer + [[nodiscard]] auto cbegin() const noexcept -> const_pointer { return begin(); } @@ -296,7 +296,7 @@ namespace kstd * * @return Reverse iterator to the first element. */ - auto rbegin() const noexcept -> const_pointer + [[nodiscard]] auto rbegin() const noexcept -> const_pointer { return _data + _size - 1; } @@ -307,7 +307,7 @@ namespace kstd * * @return Reverse iterator to the first element. */ - auto crbegin() const noexcept -> const_pointer + [[nodiscard]] auto crbegin() const noexcept -> const_pointer { return rbegin(); } @@ -329,7 +329,7 @@ namespace kstd * * @return Iterator to the element following the last element. */ - auto end() const noexcept -> const_pointer + [[nodiscard]] auto end() const noexcept -> const_pointer { return _data + _size; } @@ -340,7 +340,7 @@ namespace kstd * * @return Iterator to the element following the last element. */ - auto cend() const noexcept -> const_pointer + [[nodiscard]] auto cend() const noexcept -> const_pointer { return end(); } @@ -364,7 +364,7 @@ namespace kstd * * @return Reverse iterator to the element following the last element. */ - auto rend() const noexcept -> const_pointer + [[nodiscard]] auto rend() const noexcept -> const_pointer { return _data + size() - 1; } @@ -376,7 +376,7 @@ namespace kstd * * @return Reverse iterator to the element following the last element. */ - auto crend() const noexcept -> const_pointer + [[nodiscard]] auto crend() const noexcept -> const_pointer { return rbegin(); } @@ -402,7 +402,7 @@ namespace kstd * @return Pointer to the underlying element storage. For non-empty containers, the returned pointer compares equal * to the address of the first element. */ - auto data() const -> const_pointer + [[nodiscard]] auto data() const -> const_pointer { return _data; } @@ -425,7 +425,7 @@ namespace kstd * * @return Reference to the first element. */ - auto front() const -> const_reference + [[nodiscard]] auto front() const -> const_reference { throw_if_empty(); return *begin(); @@ -449,7 +449,7 @@ namespace kstd * * @return Reference to the last element. */ - auto back() const -> const_reference + [[nodiscard]] auto back() const -> const_reference { throw_if_empty(); return *rbegin(); @@ -490,7 +490,7 @@ namespace kstd } _capacity = new_capacity; - value_type * temp = new value_type[_capacity]{}; + auto temp = new value_type[_capacity]{}; std::ranges::copy(begin(), end(), temp); delete[] _data; _data = temp; @@ -510,7 +510,7 @@ namespace kstd } _capacity = _size; - value_type * temp = new value_type[_capacity]{}; + auto temp = new value_type[_capacity]{}; std::ranges::copy(begin(), end(), temp); delete[] _data; _data = temp; @@ -521,7 +521,7 @@ namespace kstd * * @return True if there are no elements, false if there are. */ - auto empty() const -> bool + [[nodiscard]] auto empty() const -> bool { return _size <= 0; } |
