
On Wed, Aug 17, 2011 at 10:49 AM, Brian Allison
I'm on a project which uses a C++ compiler, but with a lot of C-isms. One of those is that there are objects with pairs of functions which allocate/deallocate resources. I don't have time to fix all of the design issues with the classes that do this (yet), but within one compilation unit I'd like to remove the chance for leaks.
So - if I wanted to use boost types to wrap around 2 functions f() and g(), where each function
has a void or primitive return type takes zero or 1 argument where f() is called at some point in a scope, and then g() is called on exiting the scope from which f() is called and only if f() doesn't throw.. has its return value ignored. [Gahh....]
Is there a boost::bind (or lambda) expression that I can wrap in a type?
How do I generalize to include the possibility of a single argument?
The following works for me with gcc 4.0.1 (yeah, I know, old compiler):
#include <iostream>
#include