How it works...
The exit handlers, regardless of the method they are registered with, are called only when the program terminates normally or quickly. If termination is done in an abnormal way, via a call to std::terminate() or std::abort(), none of them are called. If any of these handlers exits via an exception, then std::terminate() is called. Exit handlers must not have any parameters and must return void. Once registered, an exit handler cannot be unregistered.
A program can install multiple handlers. The standard guarantees that at least 32 handlers can be registered with each method, although actual implementations can support any higher number. Both std::atexit() and std::at_quick_exit() are thread-safe and, therefore, can be called ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access