util/{Const,Writable}Buffer: add operator==(nullptr_t)

This commit is contained in:
Max Kellermann 2017-09-21 20:34:36 +02:00
parent 8753e558f2
commit e5c9b4cd75
3 changed files with 40 additions and 0 deletions

View File

@ -100,6 +100,14 @@ public:
return buffer.IsNull();
}
constexpr bool operator==(std::nullptr_t) const {
return buffer == nullptr;
}
constexpr bool operator!=(std::nullptr_t) const {
return buffer != nullptr;
}
/**
* Returns true if no memory was allocated so far.
*/

View File

@ -76,6 +76,14 @@ struct ConstBuffer<void> {
return data == nullptr;
}
constexpr bool operator==(std::nullptr_t) const {
return data == nullptr;
}
constexpr bool operator!=(std::nullptr_t) const {
return data != nullptr;
}
constexpr bool IsEmpty() const {
return size == 0;
}
@ -143,6 +151,14 @@ struct ConstBuffer {
return data == nullptr;
}
constexpr bool operator==(std::nullptr_t) const {
return data == nullptr;
}
constexpr bool operator!=(std::nullptr_t) const {
return data != nullptr;
}
constexpr bool IsEmpty() const {
return size == 0;
}

View File

@ -68,6 +68,14 @@ struct WritableBuffer<void> {
return data == nullptr;
}
constexpr bool operator==(std::nullptr_t) const {
return data == nullptr;
}
constexpr bool operator!=(std::nullptr_t) const {
return data != nullptr;
}
constexpr bool IsEmpty() const {
return size == 0;
}
@ -137,6 +145,14 @@ struct WritableBuffer {
return data == nullptr;
}
constexpr bool operator==(std::nullptr_t) const {
return data == nullptr;
}
constexpr bool operator!=(std::nullptr_t) const {
return data != nullptr;
}
constexpr bool IsEmpty() const {
return size == 0;
}