summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-11-07 18:00:05 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-07 18:00:05 +0100
commit68e23bca3f732f69eb1521cc73cc6d346364b3cb (patch)
treee911cbf0a79c8e1901de3637dc7f7aac384fc34d /AK
parentb88ff975371a6d251f93b22596366c07007bacf3 (diff)
downloadserenity-68e23bca3f732f69eb1521cc73cc6d346364b3cb.zip
AK: Delete operator!() and operator bool() from the Nonnull pointers
Since NonnullRefPtr and NonnullOwnPtr cannot be null, it is pointless to convert them to a bool, since it would always be true. This patch makes it an error to null-check one of these pointers.
Diffstat (limited to 'AK')
-rw-r--r--AK/NonnullOwnPtr.h3
-rw-r--r--AK/NonnullRefPtr.h3
2 files changed, 6 insertions, 0 deletions
diff --git a/AK/NonnullOwnPtr.h b/AK/NonnullOwnPtr.h
index efb3fef704..f1f07011a6 100644
--- a/AK/NonnullOwnPtr.h
+++ b/AK/NonnullOwnPtr.h
@@ -121,6 +121,9 @@ public:
CALLABLE_WHEN(unconsumed)
operator T*() { return m_ptr; }
+ operator bool() const = delete;
+ bool operator!() const = delete;
+
private:
void clear()
{
diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h
index 812457a01a..90ad50ca75 100644
--- a/AK/NonnullRefPtr.h
+++ b/AK/NonnullRefPtr.h
@@ -221,6 +221,9 @@ public:
return *m_ptr;
}
+ operator bool() const = delete;
+ bool operator!() const = delete;
+
private:
NonnullRefPtr() = delete;