Bug 709747 - Support nsCOMPtr<T>::forget(I**); r=bsmedberg

This commit is contained in:
Ms2ger 2011-12-18 10:39:22 +01:00
Родитель c7eec081e4
Коммит b2b42ad049
1 изменённых файлов: 6 добавлений и 4 удалений

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

@ -767,15 +767,17 @@ class nsCOMPtr MOZ_FINAL
return temp; return temp;
} }
template <typename I>
void void
forget( T** rhs NS_OUTPARAM ) forget( I** rhs NS_OUTPARAM )
// Set the target of rhs to the value of mRawPtr and null out mRawPtr. // Set the target of rhs to the value of mRawPtr and null out mRawPtr.
// Useful to avoid unnecessary AddRef/Release pairs with "out" // Useful to avoid unnecessary AddRef/Release pairs with "out"
// parameters. // parameters where rhs bay be a T** or an I** where I is a base class
// of T.
{ {
NS_ASSERTION(rhs, "Null pointer passed to forget!"); NS_ASSERTION(rhs, "Null pointer passed to forget!");
*rhs = 0; *rhs = get();
swap(*rhs); mRawPtr = 0;
} }
T* T*