std::set_terminate
来自cppreference.com
                    
                                        
                    
                    
                                                            
                    |   定义于头文件  <exception>
  | 
||
|   std::terminate_handler set_terminate( std::terminate_handler f ) throw();  | 
(C++11 前) | |
|   std::terminate_handler set_terminate( std::terminate_handler f ) noexcept;  | 
(C++11 起) | |
令 f 为新的全局 terminate_handler 函数并返回先前安装的 std::terminate_handler 。
| 
 此函数是线程安全的。每个对   | 
(C++11 起) | 
参数
| f | - | 指向 std::terminate_handler 类型函数的指针,或空指针 | 
返回值
之前安装的 terminate_handler ,或若未安装则为空指针值。
示例
运行此代码
#include <iostream> #include <cstdlib> #include <exception> int main() { std::set_terminate([](){ std::cout << "Unhandled exception\n"; std::abort();}); throw 1; }
可能的输出:
Unhandled exception bash: line 7: 7743 Aborted (core dumped) ./a.out
参阅
|    异常处理失败时调用的函数  (函数)  | |
|    (C++11)  | 
   获得当前的 terminate_handler   (函数)  | 
|    std::terminate 所调用的函数类型  (typedef)  |