std::nothrow 的使用心得

std::nothrow 意思是说,不要跑出异常,改为返回一个nullptr. 一般的使用场景是,建议new的时候使用,避免使用try-catch来捕捉异常.
比如:

 float m_words = new (std::nothrow)float [ words_size ];
    assert( m_words != nullptr); //or CHECK(m_words != nullptr);
posted @ 2019-01-05 16:00  龚细军  阅读(1826)  评论(0编辑  收藏  举报