From 67760f52831cbfbb0014bc4744029c3e2c9840be Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 18 Jan 2021 22:32:29 +0100 Subject: [PATCH] util/AllocatedString: support casting a nulled instance to string_view --- src/util/AllocatedString.hxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/AllocatedString.hxx b/src/util/AllocatedString.hxx index 19f17ee0e..2ca1218c9 100644 --- a/src/util/AllocatedString.hxx +++ b/src/util/AllocatedString.hxx @@ -125,7 +125,9 @@ public: } operator string_view() const noexcept { - return value; + return value != nullptr + ? string_view(value) + : string_view(); } constexpr const_pointer c_str() const noexcept {