When should std::nothrow be used?

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

What is the ideal usage of std::nothrow?

9条回答
  •  旧时难觅i
    2020-12-30 21:28

    Only very few programs should ever allocate more than 1 GiB of memory, and since modern systems overcommit memory, new will never return null or throw on these systems. Therefore, there is absolutely no point in checking the return value of new/malloc at all. Just keep your memory footprint down and let the out-of-memory-killer shoot down other processes!

提交回复
热议问题