From c06235b7581c58402f477b4642565dbcfcae9a53 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 5 Jul 2021 19:29:56 +0100 Subject: Handy operator to get a string_view of a MARIADB_STRING --- lib/mariadb_repl.h | 8 ++++++++ lib/streamSupport.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/mariadb_repl.h b/lib/mariadb_repl.h index 109385e..c57a810 100644 --- a/lib/mariadb_repl.h +++ b/lib/mariadb_repl.h @@ -8,4 +8,12 @@ #include +#include + +inline std::string_view +operator*(const MARIADB_STRING & mbstr) +{ + return {mbstr.str, mbstr.length}; +} + #endif diff --git a/lib/streamSupport.cpp b/lib/streamSupport.cpp index 2665b98..f3c88cf 100644 --- a/lib/streamSupport.cpp +++ b/lib/streamSupport.cpp @@ -18,7 +18,7 @@ namespace std { std::ostream & operator<<(std::ostream & s, const MARIADB_STRING & str) { - return s << std::string_view(str.str, str.length); + return s << *str; } std::ostream & -- cgit v1.2.3