Does it make sense to declare inline functions noexcept?
c++, c++11, inline, noexcept
Solution
let's assume that noexcept does make meaningful code-generation optimizations possible
OK
Assuming such functions are actually inlined, this would seem to require that compilers generate the equivalent of a try block around the code resulting from the inline function at the call site, because if an exception arises in that region
Not necessarily, because it might be that the compiler can look at the function body and see that it cannot possibly throw anything. Therefore the nominal exception-handling can be elided.
If the function is "fully" inlined (that is, if the inlined code contains no function calls) then I would expect that the compiler can fairly commonly make this determination -- but not for example in a case where there's a call to `vector::push_back()` and the writer of the function knows that sufficient space has been reserved but the compiler doesn't.
Be aware also that in a good implementation a try block might not actually require any code at all to be executed in the case where nothing is thrown.
With that assumption, does it make sense to declare inline functions noexcept?
Yes, in order to get whatever the assumed optimizations are of `noexcept`.
Problem
From what I can tell, the SO community is divided on whether declaring a function `noexcept` enables meaningful compiler optimizations that would not otherwise be possible. (I'm talking specifically about compiler optimizations, not library implementation optimizations based on `move_if_noexcept`.) For purposes of this question, let's assume that `noexcept` does make meaningful code-generation optimizations possible. With that assumption, does it make sense to declare `inline` functions `noexcept`? Assuming such functions are actually inlined, this would seem to require that compilers generate the equivalent of a `try` block around the code resulting from the `inline` function at the call site, because if an exception arises in that region, `terminate` must be called. Without `noexcept`, that `try` block would seem to be unnecessary. My original interest was in whether it made sense to declare Lambda functions `noexcept`, given that they are implicitly `inline`, but then I realized that the same issues arise for any `inline` function, not just Lambdas.