mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 09:12:13 -05:00
AK: Allow NonnullRawPtr
to be used in constant expressions
This commit is contained in:
parent
e2b69fe7e2
commit
6d1fa64f5f
Notes:
github-actions[bot]
2024-12-04 16:46:53 +00:00
Author: https://github.com/yyny Commit: https://github.com/LadybirdBrowser/ladybird/commit/6d1fa64f5fd Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2454 Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 13 additions and 13 deletions
|
@ -20,28 +20,28 @@ requires(!IsLvalueReference<T> && !IsRvalueReference<T>) class [[nodiscard]] Non
|
||||||
public:
|
public:
|
||||||
using ValueType = T;
|
using ValueType = T;
|
||||||
|
|
||||||
NonnullRawPtr() = delete;
|
constexpr NonnullRawPtr() = delete;
|
||||||
NonnullRawPtr(T const&&) = delete;
|
constexpr NonnullRawPtr(T const&&) = delete;
|
||||||
|
|
||||||
NonnullRawPtr(T& other)
|
constexpr NonnullRawPtr(T& other)
|
||||||
: m_ptr(&other)
|
: m_ptr(&other)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
operator bool() const = delete;
|
constexpr operator bool() const = delete;
|
||||||
bool operator!() const = delete;
|
constexpr bool operator!() const = delete;
|
||||||
|
|
||||||
operator T&() { return *m_ptr; }
|
constexpr operator T&() { return *m_ptr; }
|
||||||
operator T const&() const { return *m_ptr; }
|
constexpr operator T const&() const { return *m_ptr; }
|
||||||
|
|
||||||
[[nodiscard]] ALWAYS_INLINE T& value() { return *m_ptr; }
|
[[nodiscard]] ALWAYS_INLINE constexpr T& value() { return *m_ptr; }
|
||||||
[[nodiscard]] ALWAYS_INLINE T const& value() const { return *m_ptr; }
|
[[nodiscard]] ALWAYS_INLINE constexpr T const& value() const { return *m_ptr; }
|
||||||
|
|
||||||
[[nodiscard]] ALWAYS_INLINE T& operator*() { return value(); }
|
[[nodiscard]] ALWAYS_INLINE constexpr T& operator*() { return value(); }
|
||||||
[[nodiscard]] ALWAYS_INLINE T const& operator*() const { return value(); }
|
[[nodiscard]] ALWAYS_INLINE constexpr T const& operator*() const { return value(); }
|
||||||
|
|
||||||
ALWAYS_INLINE RETURNS_NONNULL T* operator->() { return &value(); }
|
ALWAYS_INLINE RETURNS_NONNULL constexpr T* operator->() { return &value(); }
|
||||||
ALWAYS_INLINE RETURNS_NONNULL T const* operator->() const { return &value(); }
|
ALWAYS_INLINE RETURNS_NONNULL constexpr T const* operator->() const { return &value(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T* m_ptr;
|
T* m_ptr;
|
||||||
|
|
Loading…
Reference in a new issue