34 template<
typename ... Args>
35 std::string
format(
const std::string &fmt, Args ... args)
40 auto sz = std::snprintf(
nullptr, 0, fmt.c_str(), args...);
41 ret.reserve(sz + 1); ret.resize(sz);
42 std::snprintf(&ret.front(), ret.capacity() + 1, fmt.c_str(), args...);
54 template<
typename ... Args>
57 auto new_name =
format(name, std::forward<Args>(
args)...);
60 return pthread_setname_np(new_name.c_str()) == 0;
62 pthread_t pth = pthread_self();
63 return pthread_setname_np(pth, new_name.c_str()) == 0;
73 std::ostringstream ss;
78 constexpr
size_t operator"" _KiB (
unsigned long long sz)
std::string format(const std::string &fmt, Args...args)
Make printf-formatted std::string.
const std::string to_string_ss(T &obj)
Convert to string objects with operator <<.
bool set_this_thread_name(const std::string &name, Args &&...args)
Set name to current thread, printf-like.