CXAutoReference

From cxwiki

The CXAutoReference templated class allows reference-counted objects to be passed around while automatically maintaining the correct reference count. This is a very simple and powerful tool to use for resource management. The referenced object must expose a specific reference counting interface- typically this is achieved by inheriting from DynamicReferenceCount but other techniques are permitted.
 
CXAutoReference<T> is designed to act in a manner syntactically equivalent to T* where possible.

Restrictions

Performance
Reference Cycles
Thread Safety
Conversion to C pointer
Stack-Allocated Objects
 

Techniques

Allocation / Swallow / Reference
Zero-Reference Cache
Passing by const reference
Move operator
Casting
std::swap