mirror of https://github.com/djcb/mu.git
utils: add STR_V macro for printing string_view
This commit is contained in:
parent
08534b31e6
commit
38d08bad85
|
@ -21,6 +21,7 @@
|
||||||
#define __MU_UTILS_HH__
|
#define __MU_UTILS_HH__
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
@ -253,6 +254,11 @@ to_string(const T& val)
|
||||||
return sstr.str();
|
return sstr.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert string view in something printable with %*s
|
||||||
|
*/
|
||||||
|
#define STR_V(sv__) static_cast<int>((sv__).size()), (sv__).data()
|
||||||
|
|
||||||
struct MaybeAnsi {
|
struct MaybeAnsi {
|
||||||
explicit MaybeAnsi(bool use_color) : color_{use_color} {}
|
explicit MaybeAnsi(bool use_color) : color_{use_color} {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue