/** This class behaves like a pointer to a refcounted object, but increments the
* reference count when new objects are assigned and decrements the refcounter
- * when its lifetime has expired. (similar to std::auto_ptr)
+ * when its lifetime has expired. (similar to std::unique_ptr)
*/
template<typename T>
class Ref
{
public:
- Ref(T* object = 0)
- : object(object)
+ Ref(T* object_ = 0)
+ : object(object_)
{
if(object)
object->ref();
if(object)
object->unref();
}
-
+
Ref<T>& operator= (const Ref<T>& other)
{
*this = other.get();
return *this;
}
- Ref<T>& operator= (T* object)
+ Ref<T>& operator= (T* object_)
{
- if(object)
- object->ref();
+ if(object_)
+ object_->ref();
if(this->object)
this->object->unref();
- this->object = object;
+ this->object = object_;
return *this;
}