Quick Q: What is noexcept useful for? -- StackOverflow

Quick A: Guaranteeing "this function won't throw" enables optimization opportunities.

Recently on SO:

What is noexcept useful for?

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 supposed to throw - why would I want the program to crash?

So when should I use it?

Also, how will it work along with compiling with /Eha and using _set_se_translator? This means that any line of code can throw c++ exception - because it might throw a SEH exception (Because of accessing protected memory) and it will be translated to c++ exception.

What will happen then?

Add a Comment

Comments are closed.

Comments (1)

0 0

Romário said on Dec 11, 2014 01:46 PM:

Forgive me if that's a simple minded question, but why weren't functions made noexcept by default? Then, if you wanted to throw an exception, you just needed to declare it with... "except", maybe?