The "conversion" of std::thread::id to std::string just gives you unique but otherwise useless text. In addition, you can "convert" it into a small integer, useful for easily identifying people:
std::size_t index(const std::thread::id id) { static std::size_t nextindex = 0; static std::mutex my_mutex; static std::map<std::thread::id, st::size_t> ids; std::lock_guard<std::mutex> lock(my_mutex); if(ids.find(id) == ids.end()) ids[id] = nextindex++; return ids[id]; }
Walter
source share