Skip to content

Commit

Permalink
util/StringWithHash: add nullptr constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Jan 22, 2025
1 parent 5495591 commit 5e2c8fb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/util/StringWithHash.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ struct StringWithHash {
explicit constexpr StringWithHash(std::string_view _value, std::size_t _hash) noexcept
:hash(_hash), value(_value) {}

/**
* Construct a "nulled" instance, i.e. one where IsNull()
* returns true.
*/
explicit constexpr StringWithHash(std::nullptr_t) noexcept
:value() {}

constexpr bool IsNull() const noexcept {
return value.data() == nullptr;
}

constexpr bool operator==(const StringWithHash &) const noexcept = default;
};

Expand Down

0 comments on commit 5e2c8fb

Please sign in to comment.