std:: quick_exit
From cppreference.net
C++
Utilities library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Program support utilities
|
헤더 파일에 정의됨
<cstdlib>
|
||
|
[
[
noreturn
]
]
void
quick_exit
(
int
exit_code
)
noexcept
;
|
(C++11부터) | |
리소스를 완전히 정리하지 않고 정상적인 프로그램 종료를 발생시킵니다.
std::at_quick_exit 에 전달된 함수들은 등록된 순서의 역순으로 호출됩니다. 만약 예외가 함수들 중 하나에서 벗어나려고 시도하면, std::terminate 가 호출됩니다. 등록된 함수들을 호출한 후에는 std::_Exit ( exit_code ) 를 호출합니다.
std::atexit 에 전달된 함수들은 호출되지 않습니다.
목차 |
매개변수
| exit_code | - | 프로그램의 종료 상태 |
반환값
(없음)
예제
이 코드 실행
#include <cstdlib> #include <iostream> template<int N> void quick_exit_handler() { std::cout << "quick_exit handler #" << N << std::endl; // flush is intended } void at_exit_handler() { std::cout << "at_exit handler\n"; } int main() { if (std::at_quick_exit(quick_exit_handler<1>) || std::at_quick_exit(quick_exit_handler<2>)) { std::cerr << "Registration failed\n"; return EXIT_FAILURE; } std::atexit(at_exit_handler); // the handler will not be called struct R { ~R() { std::cout << "destructor\n"; } } resource; /*...*/ std::quick_exit(EXIT_SUCCESS); std::cout << "This statement is unreachable...\n"; }
출력:
quick_exit handler #2 quick_exit handler #1
참고 항목
|
비정상적인 프로그램 종료를 유발합니다 (정리 작업 없음)
(함수) |
|
|
정리 작업과 함께 정상적인 프로그램 종료를 유발합니다
(함수) |
|
|
std::exit()
호출 시 실행될 함수를 등록합니다
(함수) |
|
|
(C++11)
|
std::quick_exit
호출 시 실행될 함수를 등록합니다
(함수) |
|
C 문서
for
quick_exit
|
|