What is noexcept useful for?

后端 未结 2 821
你的背包
你的背包 2021-02-05 02:40

I saw that C++ 11 added the noexcept keyword. But I don\'t really understand why is it useful.

If the function throws when it\'s not suppos

2条回答
  •  旧时难觅i
    2021-02-05 03:22

    The reason that the program may crash is because noexcept tells the optimizer your code won't throw. If it does - well, there's no way to predict what will happen with optimized code.

    As for MSVC++, you'd have to check what happens when they implement noexcept. From a Standard viewpoint, SEH is undefined behavior. Accessing protected memory can already crash right now.

提交回复
热议问题