How to convert std::thread::id to string in c++?

user2859777 picture user2859777 · Oct 8, 2013 · Viewed 22.4k times · Source

How to typecast std::thread::id to string in C++? I am trying to typecast output generated by std::this_thread::get_id() to a string or char array.

Answer

us2012 picture us2012 · Oct 8, 2013
auto myid = this_thread::get_id();
stringstream ss;
ss << myid;
string mystring = ss.str();