标准库头文件 <contracts> (C++26)
来自 cppreference.cn
此头文件是语言支持库的一部分。
类型 | ||
定义于命名空间
std::contracts | ||
(C++26) |
契约违规的种类 (枚举) | |
(C++26) |
发生契约违规时的求值语义 (枚举) | |
(C++26) |
导致契约违规的原因 (枚举) | |
(C++26) |
持有契约违规信息的类型 (类) | |
函数 | ||
定义于命名空间
std::contracts | ||
调用默认的契约违规处理程序 (函数) |
[编辑] 概要
// all freestanding namespace std::contracts { enum class assertion_kind : /* unspecified */ { pre = 1, post = 2, assert = 3 }; enum class evaluation_semantic : /* unspecified */ { ignore = 1, observe = 2, enforce = 3, quick_enforce = 4 }; enum class detection_mode : /* unspecified */ { predicate_false = 1, evaluation_exception = 2 }; // class contract_violation class contract_violation; void invoke_default_contract_violation_handler(const contract_violation&); }
[编辑] 类 std::contracts::contract_violation
namespace std::contracts { class contract_violation { // no user−accessible constructor public: contract_violation(const contract_violation&) = delete; contract_violation& operator=(const contract_violation&) = delete; /* see description */ ~contract_violation(); const char* comment() const noexcept; contracts::detection_mode detection_mode() const noexcept; exception_ptr evaluation_exception() const noexcept; bool is_terminating() const noexcept; assertion_kind kind() const noexcept; source_location location() const noexcept; evaluation_semantic semantic() const noexcept; }; }