std::at_quick_exit

Header: <cstdlib>

Registers the function pointed to by func to be called on quick program termination (via std::quick_exit).

# Declarations

int at_quick_exit( /*atexit-handler*/* func ) noexcept;
int at_quick_exit( /*c-atexit-handler*/* func ) noexcept;

(since C++11)

extern "C++" using /*atexit-handler*/ = void();
extern "C" using /*c-atexit-handler*/ = void();

(exposition only*)

# Parameters

# Return value

0 if the registration succeeds, nonzero value otherwise.

# Notes

The two overloads are distinct because the types of the parameter func are distinct (language linkage is part of its type).

# Example

#include <cstdlib>
#include <iostream>
 
void f1()
{
    std::cout << "pushed first" << std::endl; // flush is intentional
}
 
extern "C" void f2()
{
    std::cout << "pushed second\n";
}
 
int main()
{
    auto f3 = []
    {
        std::cout << "pushed third\n";
    };
 
    std::at_quick_exit(f1);
    std::at_quick_exit(f2);
    std::at_quick_exit(f3);
    std::quick_exit(0);
}

# See also