Search code examples
c++multithreadingstdthread

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


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.


Solution

  • auto myid = this_thread::get_id();
    stringstream ss;
    ss << myid;
    string mystring = ss.str();