123456789101112131415161718192021222324252627 |
- #pragma once
- template< class T >
- class ReferenceCounting : public T
- {
- private:
- int ref;
- public:
- ReferenceCounting()
- : T()
- {
- ref = 1;
- }
- T *getThis()
- {
- ref++;
- return this;
- }
- T *release()
- {
- if( !--ref )
- delete this;
- return 0;
- }
- };
|