From 38d08bad8559f8f2978c8be5c390f4da8c653c0d Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 26 Feb 2022 09:45:16 +0200 Subject: [PATCH] utils: add STR_V macro for printing string_view --- lib/utils/mu-utils.hh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/utils/mu-utils.hh b/lib/utils/mu-utils.hh index 8b024b49..d705c3b3 100644 --- a/lib/utils/mu-utils.hh +++ b/lib/utils/mu-utils.hh @@ -21,6 +21,7 @@ #define __MU_UTILS_HH__ #include +#include #include #include #include @@ -253,6 +254,11 @@ to_string(const T& val) return sstr.str(); } +/** + * Convert string view in something printable with %*s + */ +#define STR_V(sv__) static_cast((sv__).size()), (sv__).data() + struct MaybeAnsi { explicit MaybeAnsi(bool use_color) : color_{use_color} {}