Bug 1161627 - part 1 - add move constructor and assignment operator for already_AddRefed&& to RefPtr; r=ehsan

This change is prep work for future mass rewriting.
This commit is contained in:
Nathan Froyd 2015-05-05 13:02:21 -04:00
Родитель 9c03689307
Коммит 123e1631f7
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -237,6 +237,7 @@ public:
RefPtr(const RefPtr& aOther) : mPtr(ref(aOther.mPtr)) {} RefPtr(const RefPtr& aOther) : mPtr(ref(aOther.mPtr)) {}
MOZ_IMPLICIT RefPtr(const TemporaryRef<T>& aOther) : mPtr(aOther.take()) {} MOZ_IMPLICIT RefPtr(const TemporaryRef<T>& aOther) : mPtr(aOther.take()) {}
MOZ_IMPLICIT RefPtr(already_AddRefed<T>& aOther) : mPtr(aOther.take()) {} MOZ_IMPLICIT RefPtr(already_AddRefed<T>& aOther) : mPtr(aOther.take()) {}
MOZ_IMPLICIT RefPtr(already_AddRefed<T>&& aOther) : mPtr(aOther.take()) {}
MOZ_IMPLICIT RefPtr(T* aVal) : mPtr(ref(aVal)) {} MOZ_IMPLICIT RefPtr(T* aVal) : mPtr(ref(aVal)) {}
template<typename U> template<typename U>
@ -259,6 +260,11 @@ public:
assign(aOther.take()); assign(aOther.take());
return *this; return *this;
} }
RefPtr& operator=(already_AddRefed<T>&& aOther)
{
assign(aOther.take());
return *this;
}
RefPtr& operator=(T* aVal) RefPtr& operator=(T* aVal)
{ {
assign(ref(aVal)); assign(ref(aVal));