最佳答案
来自[expr.delete],
If the value of the operand of the delete-expression is a null pointer value, it is unspecified whether a deallocation function will be called as described above.
所以听起来像是您的用户定义或特定于类的删除运算符来处理 nullptr
。
在 [class.free] 的其他地方,当描述类的释放函数时,具有虚拟析构函数的类可以具有基于动态类型调用的释放函数。在这种情况下,释放函数不需要检查 nullptr。
关于c++ 是否需要在用户定义和特定于类的删除运算符中处理 nullptr。?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42032760/