diff --git a/AK/Iterator.h b/AK/Iterator.h index 6c7a6fd2464..7b49c01a61d 100644 --- a/AK/Iterator.h +++ b/AK/Iterator.h @@ -76,12 +76,12 @@ public: return SimpleIterator { *m_container, m_index + 1 }; } - ALWAYS_INLINE constexpr ValueType const& operator*() const + [[nodiscard]] ALWAYS_INLINE constexpr ValueType const& operator*() const requires(IsConst) { return (*m_container)[m_index]; } - ALWAYS_INLINE constexpr ValueType& operator*() const + [[nodiscard]] ALWAYS_INLINE constexpr ValueType& operator*() const requires(!IsConst) { return (*m_container)[m_index]; diff --git a/AK/NonnullOwnPtr.h b/AK/NonnullOwnPtr.h index 62af8d7dfbd..2fc212bad72 100644 --- a/AK/NonnullOwnPtr.h +++ b/AK/NonnullOwnPtr.h @@ -101,7 +101,7 @@ public: ALWAYS_INLINE RETURNS_NONNULL T* operator->() const { return ptr(); } - ALWAYS_INLINE T& operator*() const { return *ptr(); } + [[nodiscard]] ALWAYS_INLINE T& operator*() const { return *ptr(); } ALWAYS_INLINE RETURNS_NONNULL operator T*() const { return ptr(); } diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h index f3c14adf4ee..62a049c134f 100644 --- a/AK/NonnullRefPtr.h +++ b/AK/NonnullRefPtr.h @@ -168,7 +168,7 @@ public: return as_nonnull_ptr(); } - ALWAYS_INLINE T& operator*() const + [[nodiscard]] ALWAYS_INLINE T& operator*() const { return *as_nonnull_ptr(); } diff --git a/AK/Optional.h b/AK/Optional.h index d8df8a39be1..62b2a8303e2 100644 --- a/AK/Optional.h +++ b/AK/Optional.h @@ -274,8 +274,8 @@ public: return TRY(callback()); } - ALWAYS_INLINE T const& operator*() const { return value(); } - ALWAYS_INLINE T& operator*() { return value(); } + [[nodiscard]] ALWAYS_INLINE T const& operator*() const { return value(); } + [[nodiscard]] ALWAYS_INLINE T& operator*() { return value(); } ALWAYS_INLINE T const* operator->() const { return &value(); } ALWAYS_INLINE T* operator->() { return &value(); } diff --git a/AK/OwnPtr.h b/AK/OwnPtr.h index 7d2af97bb06..3d6e3650893 100644 --- a/AK/OwnPtr.h +++ b/AK/OwnPtr.h @@ -140,7 +140,7 @@ public: return m_ptr; } - T& operator*() const + [[nodiscard]] T& operator*() const { VERIFY(m_ptr); return *m_ptr; diff --git a/AK/RefPtr.h b/AK/RefPtr.h index 1aae365bf3c..4276b82b786 100644 --- a/AK/RefPtr.h +++ b/AK/RefPtr.h @@ -244,7 +244,7 @@ public: return as_nonnull_ptr(); } - ALWAYS_INLINE T& operator*() const + [[nodiscard]] ALWAYS_INLINE T& operator*() const { return *as_nonnull_ptr(); } diff --git a/Userland/Libraries/LibJS/Heap/GCPtr.h b/Userland/Libraries/LibJS/Heap/GCPtr.h index b5d25d57c0b..2ddef6058da 100644 --- a/Userland/Libraries/LibJS/Heap/GCPtr.h +++ b/Userland/Libraries/LibJS/Heap/GCPtr.h @@ -62,7 +62,7 @@ public: RETURNS_NONNULL T* operator->() const { return m_ptr; } - T& operator*() const { return *m_ptr; } + [[nodiscard]] T& operator*() const { return *m_ptr; } RETURNS_NONNULL T* ptr() const { return m_ptr; } @@ -169,7 +169,7 @@ public: return m_ptr; } - T& operator*() const + [[nodiscard]] T& operator*() const { ASSERT(m_ptr); return *m_ptr; diff --git a/Userland/Libraries/LibJS/Heap/Handle.h b/Userland/Libraries/LibJS/Heap/Handle.h index 55a2d082520..b9d579cf8d6 100644 --- a/Userland/Libraries/LibJS/Heap/Handle.h +++ b/Userland/Libraries/LibJS/Heap/Handle.h @@ -96,7 +96,7 @@ public: return cell(); } - T& operator*() const + [[nodiscard]] T& operator*() const { return *cell(); }