[英]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.