Namespaces
Variants
Actions

std::exit

From cppreference.com
< cpp‎ | utility‎ | program
 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
 
Defined in header <cstdlib>
             void exit( int exit_code );
(until C++11)
[[noreturn]] void exit( int exit_code );
(since C++11)

Causes normal program termination to occur.

Several cleanup steps are performed:

1) Objects with static storage duration are destroyed and functions registered by calling std::atexit are called:
a) Non-local objects with static storage duration are destroyed in the reverse order of the completion of their constructor.
b) Functions registered with std::atexit are called in the reverse order of their registration, except that a function is called after any previously registered functions that had already been called at the time it was registered.
c) For each function f registered with std::atexit and each non-local object obj of static storage duration,
  • if f is registered before the initialization of obj, f will only be called after the destruction of obj;
  • if f is registered after the initialization of obj, f will only be called before the destruction of obj.
d) For each local object obj with static storage duration, obj is destroyed as if a function calling the destructor of obj were registered with std::atexit at the completion of the constructor of obj.
(until C++11)
1) The destructors of objects with thread local storage duration that are associated with the current thread, the destructors of objects with static storage duration, and the functions registered with std::atexit are executed concurrently, while maintaining the following guarantees:
a) The last destructor for thread-local objects is sequenced-before the first destructor for a static object.
b) If the completion of the constructor or dynamic initialization for thread-local or static object A was sequenced-before thread-local or static object B, the completion of the destruction of B is sequenced-before the start of the destruction of A.
c) If the completion of the initialization of a static object A was sequenced-before the call to std::atexit for some function F, the call to F during termination is sequenced-before the start of the destruction of A.
d) If the call to std::atexit for some function F was sequenced-before the completion of initialization of a static object A, the start of the destruction of A is sequenced-before the call to F during termination.
e) If a call to std::atexit for some function F1 was sequenced-before the call to