From 33b9e7ac9550db22e62e35222ec65f3c5f32c9ee Mon Sep 17 00:00:00 2001 From: Jonne Ransijn Date: Sun, 17 Nov 2024 11:17:25 +0100 Subject: [PATCH] AK: Allow `NonnullRawPtr` to be used in constant expressions --- AK/NonnullRawPtr.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/AK/NonnullRawPtr.h b/AK/NonnullRawPtr.h index cb596f7af5d..eb53cba61ee 100644 --- a/AK/NonnullRawPtr.h +++ b/AK/NonnullRawPtr.h @@ -20,28 +20,28 @@ requires(!IsLvalueReference && !IsRvalueReference) class [[nodiscard]] Non public: using ValueType = T; - NonnullRawPtr() = delete; - NonnullRawPtr(T const&&) = delete; + constexpr NonnullRawPtr() = delete; + constexpr NonnullRawPtr(T const&&) = delete; - NonnullRawPtr(T& other) + constexpr NonnullRawPtr(T& other) : m_ptr(&other) { } - operator bool() const = delete; - bool operator!() const = delete; + constexpr operator bool() const = delete; + constexpr bool operator!() const = delete; - operator T&() { return *m_ptr; } - operator T const&() const { return *m_ptr; } + constexpr operator T&() { return *m_ptr; } + constexpr operator T const&() const { return *m_ptr; } - [[nodiscard]] ALWAYS_INLINE T& value() { return *m_ptr; } - [[nodiscard]] ALWAYS_INLINE T const& value() const { return *m_ptr; } + [[nodiscard]] ALWAYS_INLINE constexpr T& value() { return *m_ptr; } + [[nodiscard]] ALWAYS_INLINE constexpr T const& value() const { return *m_ptr; } - [[nodiscard]] ALWAYS_INLINE T& operator*() { return value(); } - [[nodiscard]] ALWAYS_INLINE T const& operator*() const { return value(); } + [[nodiscard]] ALWAYS_INLINE constexpr T& operator*() { return value(); } + [[nodiscard]] ALWAYS_INLINE constexpr T const& operator*() const { return value(); } - ALWAYS_INLINE RETURNS_NONNULL T* operator->() { return &value(); } - ALWAYS_INLINE RETURNS_NONNULL T const* operator->() const { return &value(); } + ALWAYS_INLINE RETURNS_NONNULL constexpr T* operator->() { return &value(); } + ALWAYS_INLINE RETURNS_NONNULL constexpr T const* operator->() const { return &value(); } private: T* m_ptr;