Answer
Exception safety describes which program guarantees remain when an operation throws. • The no-throw guarantee means the operation will not emit an exception. • The strong guarantee leaves observable state unchanged on failure. • The basic guarantee preserves invariants and prevents resource leaks, though values may change.
💡 C++ Example
void add_name(std::vector<std::string>& names, std::string name) {
names.push_back(std::move(name));
}
⚡ Quick Revision
Exception safety preserves invariants and resources, with basic, strong, or no-throw guarantees.