Commit 04731fb7 authored by Max Kellermann's avatar Max Kellermann

util/StringPointer: add operator==(std::nullptr_t)

parent 12ff5a54
/* /*
* 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#ifndef STRING_POINTER_HXX #ifndef STRING_POINTER_HXX
#define STRING_POINTER_HXX #define STRING_POINTER_HXX
#include <cstddef>
/** /**
* Simple OO wrapper for a const string pointer. * Simple OO wrapper for a const string pointer.
*/ */
...@@ -52,6 +54,14 @@ public: ...@@ -52,6 +54,14 @@ public:
constexpr StringPointer(const_pointer _value) noexcept constexpr StringPointer(const_pointer _value) noexcept
:value(_value) {} :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 * Check if this is a "nulled" instance. A "nulled" instance
* must not be used. * must not be used.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment