diff options
author | Max Kellermann <max@musicpd.org> | 2021-01-21 21:08:50 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2021-01-21 21:08:52 +0100 |
commit | 04731fb7cccfc586812d80d62fd593db8996cb9f (patch) | |
tree | 711bea36f1c536cda31902d52be3d421baf89335 /src/util | |
parent | 12ff5a547f914758e5de5ed1aa55d0f02c075b53 (diff) |
util/StringPointer: add operator==(std::nullptr_t)
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/StringPointer.hxx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/util/StringPointer.hxx b/src/util/StringPointer.hxx index 77c48370a..ae2afcd8d 100644 --- a/src/util/StringPointer.hxx +++ b/src/util/StringPointer.hxx @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 Max Kellermann <max.kellermann@gmail.com> + * Copyright 2015-2021 Max Kellermann <max.kellermann@gmail.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,6 +30,8 @@ #ifndef STRING_POINTER_HXX #define STRING_POINTER_HXX +#include <cstddef> + /** * Simple OO wrapper for a const string pointer. */ @@ -52,6 +54,14 @@ public: constexpr StringPointer(const_pointer _value) noexcept :value(_value) {} + constexpr bool operator==(std::nullptr_t) const noexcept { + return value == nullptr; + } + + constexpr bool operator!=(std::nullptr_t) const noexcept { + return value != nullptr; + } + /** * Check if this is a "nulled" instance. A "nulled" instance * must not be used. |