我正在学习C ++,目前正在摆弄以下代码:
class Bar;
struct Callback {
virtual void Continue(Bar&) = 0;
};
// ...
void Foo(Bar& _x, Callback& result)
{
// Do stuff with _x
if(/* some condition */) {
// TODO: Force unwind of stack
result.Continue(_x);
return;
}
// Do more stuff with _x
if(/* some other condition */) {
// TODO: Force unwind of stack
result.Continue(_x);
return;
}
// TODO: Force unwind of stack
Bar y; // allocate something on the stack
result.Continue(y);
}
Run Code Online (Sandbox Code Playgroud)
主要思想是,我知道在每个站点都result.Continue被调用时,该函数 …