C++ new 失败不抛异常的简单处理方式

  从c转换到c++的程序员,经常喜欢 p = new type, if (p ),  除非增加相关编译选项,否则new失败会抛异常出去, 最简单的办法就是:


#include <new>


auto p = new (std::nothrow) type;

if ( nullptr == p )



猜你喜欢

转载自blog.csdn.net/lsheevyfg/article/details/80249301
今日推荐