简体   繁体   English

为什么std :: allocator :: deallocate不是noexcept?

[英]Why is std::allocator::deallocate not noexcept?

The C++ specification (ISO/IEC 14882:2011 + ISO/IEC 14882:2014) defines in Table 28 — Allocator requirements for deallocate: C ++规范(ISO / IEC 14882:2011 + ISO / IEC 14882:2014)在表28中定义了解除分配的分配器要求:

All n T objects in the area pointed to by p shall be destroyed prior to this call. p指向的区域中的所有n个T对象应在此呼叫之前销毁。 n shall match the value passed to allocate to obtain this memory. n应匹配传递给allocate的值以获取此内存。 Does not throw exceptions. 不抛出异常。

But why is deallocate still not noexcept? 但为什么deallocate仍然不是 noexcept?

这是狭窄的契约(例如,如果你传递一个未通过allocate返回的指针,则会导致未定义的行为),因此根据标准库的通常策略,它不会标记为noexcept。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM