// OK: but repetitive auto q = make_unique<Foo>(7); // Better: no repetition of Foo // Not exception-safe be destroyed, and the memory-allocated //for it will leak. f(unique_ptr<Foo>(new Foo()), bar()); // Exception-safe
争取异常安全(exception-safe)的代码 30. 理解 inline 化的介入和排除 31. 最小化文件之间的编译依赖 32. 争取异常安全(exception-safe)的代码 即使当异常被抛出时,异常安全的函数不会泄露资源,也不允许数据结构被恶化。这样的函数提供基本的,强力的,或者不抛出保证。
精心设计的函数是异常安全的(exception-safe),这意味着他们至少提供了最基本的异常安全保证(即基本承诺basic guarantee),这样的函数向调用者确保了即使有一个异常产生了,程序的不变量依旧是完整的
条款29:为“异常安全”而努力是值得的 请记住 ■ 异常安全函数(Exception-safe functions)即使发生异常也不会泄漏资源或允许任何数据结构败坏。
handler 事件处理器 evidence 证据 exception 异常 exception declaration 异常声明 exception handling 异常处理、异常处理机制 exception-safe
event handler 事件处理器 evidence 证据 exception 异常 exception declaration 异常声明 exception handling 异常处理、异常处理机制 exception-safe
事件处理器 evidence 证据 exception 异常 exception declaration 异常声明 exception handling 异常处理、异常处理机制 exception-safe
事件处理器 evidence 证据 exception 异常 exception declaration 异常声明 exception handling 异常处理、异常处理机制 exception-safe
指向对象内部(以增加封装性、使 const 成员函数的行为更像 const、降低 “虚吊号码牌”(dangling handles,如悬空指针等)的可能性) 为 “异常安全” 而努力是值得的(异常安全函数(Exception-safe
指向对象内部(以增加封装性、使 const 成员函数的行为更像 const、降低 “虚吊号码牌”(dangling handles,如悬空指针等)的可能性) 为 “异常安全” 而努力是值得的(异常安全函数(Exception-safe