简体   繁体   English

如果 nothrow new 返回 nullptr,是否调用构造函数?

[英]Is constructor called if nothrow new return nullptr?

If I use new and get std::bad_alloc compiler do not call constructor because of exception.如果我使用new并获取std::bad_alloc编译器不要因为异常调用构造函数。 But how does it works with the nothrow new cause we get pointer in every case?但是它如何与nothrow new一起工作,因为我们在每种情况下都得到指针? Is there special paragraph in standard for this case?这种情况的标准中是否有特殊段落?

[expr.new]/16 ... if the allocation function returns null, initialization shall not be done, the deallocation function shall not be called, and the value of the new-expression shall be null. [expr.new]/16 ... if the allocation function returns null, initialization shall not be done, the deallocation function shall not be called, and the value of the new-expression shall be null.

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

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