When should std::nothrow be used?

后端 未结 9 1545
误落风尘
误落风尘 2020-12-30 20:27

What is the ideal usage of std::nothrow?

9条回答
  •  说谎
    说谎 (楼主)
    2020-12-30 21:14

    Porting a C program to C++. Your C program has all those checks in there, after every malloc, and no notion of exceptions. So it's much simpler to change every malloc to new (nothrow) than to wrap every malloc in a try block.

提交回复
热议问题