mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 15:10:19 +00:00
AK+LibJS: Add [[nodiscard]]
to operator*
in common types
The order of precedence with the `*` operator sometimes makes it a bit harder to detect whether or not the result is actually used. Let's fail compilation if anyone tries to discard the result.
This commit is contained in:
parent
5ab07f277c
commit
0de403fede
Notes:
github-actions[bot]
2024-10-25 07:16:17 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/0de403fede6 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1946
8 changed files with 11 additions and 11 deletions
|
@ -76,12 +76,12 @@ public:
|
||||||
return SimpleIterator { *m_container, m_index + 1 };
|
return SimpleIterator { *m_container, m_index + 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE constexpr ValueType const& operator*() const
|
[[nodiscard]] ALWAYS_INLINE constexpr ValueType const& operator*() const
|
||||||
requires(IsConst<ValueType>)
|
requires(IsConst<ValueType>)
|
||||||
{
|
{
|
||||||
return (*m_container)[m_index];
|
return (*m_container)[m_index];
|
||||||
}
|
}
|
||||||
ALWAYS_INLINE constexpr ValueType& operator*() const
|
[[nodiscard]] ALWAYS_INLINE constexpr ValueType& operator*() const
|
||||||
requires(!IsConst<ValueType>)
|
requires(!IsConst<ValueType>)
|
||||||
{
|
{
|
||||||
return (*m_container)[m_index];
|
return (*m_container)[m_index];
|
||||||
|
|
|
@ -101,7 +101,7 @@ public:
|
||||||
|
|
||||||
ALWAYS_INLINE RETURNS_NONNULL T* operator->() const { return ptr(); }
|
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(); }
|
ALWAYS_INLINE RETURNS_NONNULL operator T*() const { return ptr(); }
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ public:
|
||||||
return as_nonnull_ptr();
|
return as_nonnull_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE T& operator*() const
|
[[nodiscard]] ALWAYS_INLINE T& operator*() const
|
||||||
{
|
{
|
||||||
return *as_nonnull_ptr();
|
return *as_nonnull_ptr();
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,8 +274,8 @@ public:
|
||||||
return TRY(callback());
|
return TRY(callback());
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE T const& operator*() const { return value(); }
|
[[nodiscard]] ALWAYS_INLINE T const& operator*() const { return value(); }
|
||||||
ALWAYS_INLINE T& operator*() { return value(); }
|
[[nodiscard]] ALWAYS_INLINE T& operator*() { return value(); }
|
||||||
|
|
||||||
ALWAYS_INLINE T const* operator->() const { return &value(); }
|
ALWAYS_INLINE T const* operator->() const { return &value(); }
|
||||||
ALWAYS_INLINE T* operator->() { return &value(); }
|
ALWAYS_INLINE T* operator->() { return &value(); }
|
||||||
|
|
|
@ -140,7 +140,7 @@ public:
|
||||||
return m_ptr;
|
return m_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
T& operator*() const
|
[[nodiscard]] T& operator*() const
|
||||||
{
|
{
|
||||||
VERIFY(m_ptr);
|
VERIFY(m_ptr);
|
||||||
return *m_ptr;
|
return *m_ptr;
|
||||||
|
|
|
@ -244,7 +244,7 @@ public:
|
||||||
return as_nonnull_ptr();
|
return as_nonnull_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE T& operator*() const
|
[[nodiscard]] ALWAYS_INLINE T& operator*() const
|
||||||
{
|
{
|
||||||
return *as_nonnull_ptr();
|
return *as_nonnull_ptr();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
|
|
||||||
RETURNS_NONNULL T* operator->() const { return m_ptr; }
|
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; }
|
RETURNS_NONNULL T* ptr() const { return m_ptr; }
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ public:
|
||||||
return m_ptr;
|
return m_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
T& operator*() const
|
[[nodiscard]] T& operator*() const
|
||||||
{
|
{
|
||||||
ASSERT(m_ptr);
|
ASSERT(m_ptr);
|
||||||
return *m_ptr;
|
return *m_ptr;
|
||||||
|
|
|
@ -96,7 +96,7 @@ public:
|
||||||
return cell();
|
return cell();
|
||||||
}
|
}
|
||||||
|
|
||||||
T& operator*() const
|
[[nodiscard]] T& operator*() const
|
||||||
{
|
{
|
||||||
return *cell();
|
return *cell();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue