mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
AK: Mark Optional getters as [[nodiscard]]
There is no reason to call a getter without observing the result, doing so indicates an error in the code. Mark these methods as [[nodiscard]] to find these cases.
This commit is contained in:
parent
8752a27519
commit
3356f438ca
Notes:
sideshowbarker
2024-07-18 22:16:16 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/3356f438caa Pull-request: https://github.com/SerenityOS/serenity/pull/5353
1 changed files with 5 additions and 5 deletions
|
@ -124,20 +124,20 @@ public:
|
|||
new (&m_storage) T(forward<Parameters>(parameters)...);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool has_value() const { return m_has_value; }
|
||||
[[nodiscard]] ALWAYS_INLINE bool has_value() const { return m_has_value; }
|
||||
|
||||
ALWAYS_INLINE T& value()
|
||||
[[nodiscard]] ALWAYS_INLINE T& value()
|
||||
{
|
||||
ASSERT(m_has_value);
|
||||
return *reinterpret_cast<T*>(&m_storage);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const T& value() const
|
||||
[[nodiscard]] ALWAYS_INLINE const T& value() const
|
||||
{
|
||||
return value_without_consume_state();
|
||||
}
|
||||
|
||||
T release_value()
|
||||
[[nodiscard]] T release_value()
|
||||
{
|
||||
ASSERT(m_has_value);
|
||||
T released_value = move(value());
|
||||
|
@ -146,7 +146,7 @@ public:
|
|||
return released_value;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE T value_or(const T& fallback) const
|
||||
[[nodiscard]] ALWAYS_INLINE T value_or(const T& fallback) const
|
||||
{
|
||||
if (m_has_value)
|
||||
return value();
|
||||
|
|
Loading…
Add table
Reference in a new issue