Assume I have this function
void foo() noexcept
{
// Safely noexcept code.
}
And then this class:
class Bar
{
Bar(const Bar&) { ... } // Is not noexcept, so might throw
// Non movable:
Bar(Bar&&) = delete;
};
Now, I need to modify foo() to receive a Bar by value:
void foo(Bar bar) // noexcept?
{
// Safely noexcept code
}
I assume the copy of Bar is done before the call to foo, so the code of foo could theoretically still be noexcept, but I am not sure how is that at C++ level defined. Does foo need to get the noexcept deleted or is the caller who might throw when coping Bar? Does it depend on the call mode(stdcall, farcall, etc..) or compiler? Update: In other questions I did not found any reference to the call convention. That should make a difference on the behavior. I supose.
foo
could staynoexcept
. copy (if any) happens before the call. – Skippet