全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Exception-safety guarantees?

又称: exception-safety guarantee

Definition 1.16 University Computer Science — Year 2 · 第 1 章 — From C to C++: Classes and Resource Management

An operation gives the basic guarantee if, when it throws, no resource is leaked and every object it touched still satisfies its invariant, though its value may have changed. It gives the strong guarantee if, when it throws, the state is exactly as before the call (“commit or roll back”). It gives the no-throw guarantee if it never throws; a function declares it with noexcept.

The roster of  before the call and after a call throws on the empty name. The basic guarantee leaves some valid state, here with Cora and Dev added; the strong guarantee leaves the state of before.
The roster of Listing 1.11 before the call and after a call throws on the empty name. The basic guarantee leaves some valid state, here with Cora and Dev added; the strong guarantee leaves the state of before.
在原文中阅读 →