Add std:🧵:id formatter

This commit is contained in:
Victor Zverovich 2022-05-17 16:31:06 -07:00
parent 9730fb0156
commit 6bf039d750
2 changed files with 11 additions and 1 deletions

View File

@ -8,7 +8,9 @@
#ifndef FMT_STD_H_
#define FMT_STD_H_
#include "format.h"
#include <thread>
#include "ostream.h"
#if FMT_HAS_INCLUDE(<version>)
# include <version>
@ -27,4 +29,8 @@ struct fmt::formatter<std::filesystem::path> : formatter<string_view> {
};
#endif
FMT_BEGIN_NAMESPACE
template <> struct formatter<std::thread::id> : ostream_formatter {};
FMT_END_NAMESPACE
#endif // FMT_STD_H_

View File

@ -14,3 +14,7 @@ TEST(std_test, path) {
EXPECT_EQ(fmt::format("{:8}", std::filesystem::path("foo")), "foo ");
#endif
}
TEST(std_test, thread_id) {
EXPECT_FALSE(fmt::format("{}", std::this_thread::get_id()).empty());
}