Comment by ufo
5 years ago
You can still use this trick in C++ if you ensure that the return statements are outside the scopes that have the RAII objects. It's awkward but it's better than nothing. https://godbolt.org/z/cnbjaK85T
void foo(int x) {
{
MyObj obj;
// ...
}
return bar(x); // tail call
}
No comments yet
Contribute on Hacker News ↗