1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:57:46 +00:00

AK: Prevent confusing silent misuse of ByteBuffer

Thankfully, this hasn't happened in any other code yet, but it happened
while I was trying something out. Using '==' on two ByteBuffers to check
whether they're equal seemed straight-forward, so I ran into the trap.
This commit is contained in:
Ben Wiederhake 2020-08-22 16:10:19 +02:00 committed by Andreas Kling
parent 901ed9b85d
commit 4acdb60ba3
3 changed files with 74 additions and 10 deletions

View file

@ -147,6 +147,14 @@ public:
bool operator!() const { return is_null(); }
bool is_null() const { return m_impl == nullptr; }
// Disable default implementations that would use surprising integer promotion.
bool operator==(const ByteBuffer& other) const;
bool operator!=(const ByteBuffer& other) const { return !(*this == other); }
bool operator<=(const ByteBuffer& other) const = delete;
bool operator>=(const ByteBuffer& other) const = delete;
bool operator<(const ByteBuffer& other) const = delete;
bool operator>(const ByteBuffer& other) const = delete;
u8& operator[](size_t i)
{
ASSERT(m_impl);