std::thread::~thread(3)
π NAME π
std::thread::~thread - std::thread::~thread
okay bestie, this is the std::thread::~thread page from the C++ Standard Libary manual, and we are officially in destructor territory π
β¨
β¨ Synopsis β¨
~thread(); (since C++11)
Destroys the thread object. Thatβs the job. Thatβs the whole vibe. π
β οΈ If*thishas an associated thread (joinable() == true),std::terminate()is called. Likeβ¦ not a drill, bestie. ππ
π¦ Notes π¦
A thread object does not have an associated thread (and is safe to destroy) after:
- it was default-constructed.
- it was moved from.
join()has been called.detach()has been called.
so like, those are the green flags for destroying it safely π«Άβ¨
πΈ Example πΈ
// Run this code
#include <thread>
using namespace std::chrono_literals;
int main()
{
auto bleah = std::thread{[]{ std::this_thread::sleep_for(13ms); }};
} // ~thread calls std::terminate()
π Possible output π
terminate called without an active exception
π See also π
destructorβ if the thread is joinable, then a stop is requested and the thread joins (public member function ofstd::jthread) π
k bye bestie, source/version is http://cppreference.com, dated 2024.06.10 β stay joined or get terminated, iykyk ππ
π«Ά
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms