- template<typename T>
- struct Binder: Base
- {
- const T &obj;
-
- Binder(const T &o): obj(o) { obj.bind(); }
- ~Binder() { obj.unbind(); }
- };
-
- Base *binder;
-
-public:
- template<typename T>
- Bind(const T &o): binder(new Binder<T>(o)) { }
- ~Bind() { delete binder; }
-};