From dd79eed4959f57e0c94d0a8038202fc2bc3ab087 Mon Sep 17 00:00:00 2001 From: Yuriy Chernyshov Date: Sun, 17 Dec 2023 07:30:21 +0100 Subject: [PATCH] Introduce convenient implicit operator string_view (#8181) Co-authored-by: Derek Bailey --- include/flatbuffers/string.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/flatbuffers/string.h b/include/flatbuffers/string.h index 97e399fd6..00cc18c9a 100644 --- a/include/flatbuffers/string.h +++ b/include/flatbuffers/string.h @@ -31,6 +31,11 @@ struct String : public Vector { flatbuffers::string_view string_view() const { return flatbuffers::string_view(c_str(), size()); } + + /* implicit */ + operator flatbuffers::string_view() const { + return flatbuffers::string_view(c_str(), size()); + } #endif // FLATBUFFERS_HAS_STRING_VIEW // clang-format on