From a8b7054db545fbdea0544883ea6746bfc3a95087 Mon Sep 17 00:00:00 2001 From: Yuriy Chernyshov Date: Fri, 1 Dec 2023 11:21:41 +0100 Subject: [PATCH] Introduce convenient implicit operator string_view --- include/flatbuffers/string.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/flatbuffers/string.h b/include/flatbuffers/string.h index 97e399fd64a..00cc18c9a76 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