STL's ScopeWarden class looks promising. I'm a bit disappointed that c++ is limited in the area of functor and lambda storing. I wonder why they have not done anything about it. Is it not common enough or do people just bite the bullet and take the dynamic allocation overhead and hope the cpu's get faster next year ?
Somebody from the c++ group should really comment on this.