When should std::nothrow be used?

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

What is the ideal usage of std::nothrow?

9条回答
  •  礼貌的吻别
    2020-12-30 21:06

    You use std::nothrow when you want to have to check for null after every new. A lot of legacy code needed it when the first version of the standard was made. A lot of legacy code written afterward use it too because people where paranoid of exceptions. Occasionally you'll run into someone that still is.

    It's so very rare that you'd actually want to do this that it even took me a second to remember WTF you were talking about.

提交回复
热议问题