std::thread::operator=(3)

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

🌈 std::thread::operator= β€” C++ Standard Library, manual page std::thread::operator=(3) 🌈

okay bestie, welcome to the std::thread::operator=(3) page β€” yes, the move-assignment operator for std::thread, and it’s giving β€œI have very specific rules and one of them is std::terminate()” energy. πŸ’…


πŸ’– NAME πŸ’–

std::thread::operator= β€” literally std::thread::operator=. That’s the name, no notes. πŸŽ€

✨ Synopsis ✨

thread& operator=( thread&& other ) noexcept;  (since C++11)

If *this still has an associated running thread (i.e. joinable() == true), it calls std::terminate(). Otherwise, it assigns the state of other to *this and sets other to a default constructed state.

After this call, this->get_id() is equal to the value of other.get_id() prior to the call, and other no longer represents a thread of execution. fr fr, that’s the whole glow-up. ✨

🚨 warning bestie: if *this is still joinable, this operator calls std::terminate(). That is not a drill, that is the dramatic part. πŸ’€

🫢 Parameters 🫢

  • other β€” another thread object to assign to this thread object. basically the thread object getting moved into *this, slay. πŸ¦‹

πŸ‘‘ Return value πŸ‘‘

  • *this β€” it returns *this. main character return, no cap. πŸ’–

sign-off: this page came from http://cppreference.com, dated 2024.06.10, and it’s the std::thread::operator=(3) manual page. mwah, stay joinable-safe, bestie πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from