What is the noexcept keyword and when to use it?

2

What does keyword noexcept in C ++ and in what situation should it be used?

    
asked by anonymous 07.07.2018 / 23:15

1 answer

2

Two ways:

Specifier attribute

Indicates that the function can not throw an exception, which allows a series of optimizations, and the compiler better understands the semantics. Once put can not take out, is part of the contract. use it whenever possible. In fact, until a new form of exception comes in, in C ++ 20 or C ++ 23, avoid exceptions.

In C ++ 14 it was a bit different, but do not consider this form, prefer that of C ++ 17.

See more at documentation .

Operator

Used essentially for metaprogramming / reflection, enabling selections and specializations to be compiled according to what you find. Something much more advanced. It is a way to query during compilation if the function can not throw an exception.

See more on documentation .

    
07.07.2018 / 23:47