static const T *cur_obj;
Bindable() { }
+ ~Bindable() { if(cur_obj==this) T::unbind(); }
static bool set_current(const T *obj)
{
template<typename T>
class BindableWithDefault: protected Bindable<T>
{
+ friend class Bindable<T>;
+
protected:
BindableWithDefault() { }
+ ~BindableWithDefault() { if(this==&default_object()) Bindable<T>::set_current(0); }
public:
static const T *current()
static void unbind()
{
- default_object().bind();
+ if(Bindable<T>::cur_obj)
+ default_object().bind();
}
static const T &default_object()