int foo() {
Magic magic;
if (something) return 1;
if (something_else) return 2;
return 0;
}
Let's say that I have a function such as the above;
- is it possible for
magic
destructor to refer to the value the function is about to return?
class Magic {
~Magic() {
int return_code = <magic spell>;
std::cout << "the method returns" << return_code;
}
};
-- EDIT --
For example, golang has named return variables that you can access and/or modify from a defer statement - after they are "returned" from the body of the function.