std::thread::id(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🧡 std::thread::id(3) 🧡

okay bestie, this is the std::thread::id(3) page from the C++ Standard Libary manual, and we are about to make this tiny ID class make sense. no cap. πŸ’–

πŸ’– NAME πŸ’–

std::thread::id - std::thread::id

(Yes, the NAME line is literally std::thread::id on both sides. we keep the facts exactly as they are, even when they're silly. πŸŽ€)

🌈 Synopsis 🌈

Defined in header <thread>
class thread::id;           (since C++11)

The class thread::id is a lightweight, trivially copyable class that serves as a unique identifier of std::thread and std::jthread (since C++20) objects. πŸ¦‹

Instances of this class may also hold the special distinct value that does not represent any thread. Once a thread has finished, the value of std::thread::id may be reused by another thread. that's important, bestie β€” IDs are not forever stickers. 🫢

This class is designed for use as key in associative containers, both ordered and unordered. so yes, it's giving "put me in a map" energy. πŸ”₯

πŸ’… Member functions πŸ’…

  • constructor β€” constructs an id that does not represent a thread (public member function)

πŸ¦‹ Non-member functions πŸ¦‹

okay the non-member section is lowkey doing an annotation tornado, so I'm keeping the exact order and every little crumb:

  • operator==
  • operator!=
  • operator<
  • operator<=
  • operator>
  • operator>= β€” next to this the page says compares two thread::id objects
  • operator<=> β€” (function)
  • (removed in C++20)
  • (removed in C++20)
  • (removed in C++20)
  • (removed in C++20)
  • (removed in C++20)
  • (C++20)
  • operator<< β€” serializes a thread::id object (function template)

That's the whole cluster. The vibes are chaotic but the facts are intact. πŸ’€

🌸 Helper classes 🌸

  • std::hash<std::thread::id> β€” hash support for std::thread::id (C++11) (class template specialization)
  • std::formatter<std::thread::id> β€” formatting support for thread::id (C++23) (class template specialization)

πŸ‘‘ See also πŸ‘‘

  • get_id β€” returns the id of the thread (public member function)
  • get_id β€” returns the thread id of the current thread (C++11) (function)

πŸ’– okay that's the whole page, bestie. source: http://cppreference.com, version/date: 2024.06.10, and the page is std::thread::id(3). slay, you're now an ID girlie. πŸŽ€βœ¨

πŸ“¦ where this page comes from