utils: add STR_V macro for printing string_view

This commit is contained in:
Dirk-Jan C. Binnema 2022-02-26 09:45:16 +02:00
parent 08534b31e6
commit 38d08bad85
1 changed files with 6 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#define __MU_UTILS_HH__
#include <string>
#include <string_view>
#include <sstream>
#include <vector>
#include <chrono>
@ -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<int>((sv__).size()), (sv__).data()
struct MaybeAnsi {
explicit MaybeAnsi(bool use_color) : color_{use_color} {}