summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-09-21 20:34:36 +0200
committerMax Kellermann <max@musicpd.org>2017-09-21 20:34:36 +0200
commite5c9b4cd75f3202215da8fe9ee437525e8e8d278 (patch)
tree525ea68f5122730ba3cc44f599f258f4f3799b5b /src
parent8753e558f24e177a355722f27463d9742b2bbd66 (diff)
util/{Const,Writable}Buffer: add operator==(nullptr_t)
Diffstat (limited to 'src')
-rw-r--r--src/util/AllocatedArray.hxx8
-rw-r--r--src/util/ConstBuffer.hxx16
-rw-r--r--src/util/WritableBuffer.hxx16
3 files changed, 40 insertions, 0 deletions
diff --git a/src/util/AllocatedArray.hxx b/src/util/AllocatedArray.hxx
index 1a726a323..3b14eb114 100644
--- a/src/util/AllocatedArray.hxx
+++ b/src/util/AllocatedArray.hxx
@@ -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.
*/
diff --git a/src/util/ConstBuffer.hxx b/src/util/ConstBuffer.hxx
index 8d36ac08b..9e780d78b 100644
--- a/src/util/ConstBuffer.hxx
+++ b/src/util/ConstBuffer.hxx
@@ -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;
}
diff --git a/src/util/WritableBuffer.hxx b/src/util/WritableBuffer.hxx
index 8272b012d..3155d5503 100644
--- a/src/util/WritableBuffer.hxx
+++ b/src/util/WritableBuffer.hxx
@@ -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;
}