Bläddra i källkod

Kernel: Delete the rvalue-ref qualified version of KResultOr::value()

This makes calling value() on a temporary KResultOr be a compile-time
error. This exposed a number of missing error checks (fixed in the
preceding commits.)
Andreas Kling 3 år sedan
förälder
incheckning
74ce098d58
1 ändrade filer med 4 tillägg och 2 borttagningar
  1. 4 2
      Kernel/KResult.h

+ 4 - 2
Kernel/KResult.h

@@ -138,18 +138,20 @@ public:
 
     [[nodiscard]] KResult result() const { return m_is_error ? m_error : KSuccess; }
 
-    [[nodiscard]] ALWAYS_INLINE T& value()
+    [[nodiscard]] ALWAYS_INLINE T& value() &
     {
         VERIFY(!m_is_error);
         return *reinterpret_cast<T*>(&m_storage);
     }
 
-    [[nodiscard]] ALWAYS_INLINE const T& value() const
+    [[nodiscard]] ALWAYS_INLINE T const& value() const&
     {
         VERIFY(!m_is_error);
         return *reinterpret_cast<T*>(&m_storage);
     }
 
+    T value() && = delete;
+
     [[nodiscard]] ALWAYS_INLINE T release_value()
     {
         VERIFY(!m_is_error);