summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2020-08-22 16:45:52 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-22 17:18:14 +0200
commitb4f26c2b31109c1cc47f016cb8aa5f362e40a281 (patch)
tree89d04baa72600448122d5c3c8b320e27af4e3ab5 /AK
parenta6314f2ce6c6d30837087380fcca71eb018fd550 (diff)
downloadserenity-b4f26c2b31109c1cc47f016cb8aa5f362e40a281.zip
AK: Prevent confusing silent misuse of Userspace<T>
Diffstat (limited to 'AK')
-rw-r--r--AK/Userspace.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/AK/Userspace.h b/AK/Userspace.h
index d7586b7ef7..eb6bb0c44a 100644
--- a/AK/Userspace.h
+++ b/AK/Userspace.h
@@ -48,6 +48,13 @@ public:
operator bool() const { return m_ptr; }
operator FlatPtr() const { return (FlatPtr)m_ptr; }
+ // Disable default implementations that would use surprising integer promotion.
+ bool operator==(const Userspace&) const = delete;
+ bool operator<=(const Userspace&) const = delete;
+ bool operator>=(const Userspace&) const = delete;
+ bool operator<(const Userspace&) const = delete;
+ bool operator>(const Userspace&) const = delete;
+
#ifdef KERNEL
Userspace(FlatPtr ptr)
: m_ptr(ptr)
@@ -86,5 +93,5 @@ inline Userspace<T> static_ptr_cast(const Userspace<U>& ptr)
}
-using AK::Userspace;
using AK::static_ptr_cast;
+using AK::Userspace;