3

I know about std::this_thread::get_id(), and about std::thread::native_handle(). But - the latter is a method of std::thread, while the former gets you an ID - and you can't construct an std::thread from an std::thread::id.

So - how can I otherwise "combine" these two and get the current thread's native handle, a-l-a pthread_self()?

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • 1
    related: https://stackoverflow.com/questions/42262750/how-to-get-stdthread-of-current-thread – YSC Oct 25 '18 at 08:05
  • You can't get a `std::thread` for the calling thread. You will have to use platform specific APIs directly, like `GetCurrentThread()` on Windows and `pthread_self()` on POSIX. – Remy Lebeau Oct 25 '18 at 08:07
  • @RemyLebeau: You mean, I can't with standard C++11? – einpoklum Oct 25 '18 at 08:07
  • 1
    See Howard Hinnant's [answer](https://stackoverflow.com/questions/16259257/c11-native-handle-is-not-a-member-of-stdthis-thread) – WhiZTiM Oct 25 '18 at 08:07

0 Answers0