The only way to release automatic variables is to let them fall out of scope:
void bar() {
Foo f1(arg1, arg2);
f1.doSomething();
{
Foo f2(arg3, arg4);
f2.doSomething();
// other stuff ...
// f2 dies here.
}
{
Foo f3(arg5, arg6); // allocated on stack, possibly overlapping f2's old spot
f3.doSomething();
// ...
// f3 dies here.
}
// f1 dies here.
}