mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1195154 - Replace operator overloads for comparing nsRefPtr to 0 with those for comparing to nullptr. r=froydnj
This commit is contained in:
parent
a12861eafc
commit
539c5ebd2f
@ -549,42 +549,34 @@ operator!=(U* aLhs, const nsRefPtr<T>& aRhs)
|
||||
return const_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get());
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
class nsRefPtrZero;
|
||||
} // namespace detail
|
||||
|
||||
// Comparing an |nsRefPtr| to |0|
|
||||
// Comparing an |nsRefPtr| to |nullptr|
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
operator==(const nsRefPtr<T>& aLhs, ::detail::nsRefPtrZero* aRhs)
|
||||
// specifically to allow |smartPtr == 0|
|
||||
operator==(const nsRefPtr<T>& aLhs, decltype(nullptr))
|
||||
{
|
||||
return static_cast<const void*>(aLhs.get()) == reinterpret_cast<const void*>(aRhs);
|
||||
return aLhs.get() == nullptr;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
operator==(::detail::nsRefPtrZero* aLhs, const nsRefPtr<T>& aRhs)
|
||||
// specifically to allow |0 == smartPtr|
|
||||
operator==(decltype(nullptr), const nsRefPtr<T>& aRhs)
|
||||
{
|
||||
return reinterpret_cast<const void*>(aLhs) == static_cast<const void*>(aRhs.get());
|
||||
return nullptr == aRhs.get();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
operator!=(const nsRefPtr<T>& aLhs, ::detail::nsRefPtrZero* aRhs)
|
||||
// specifically to allow |smartPtr != 0|
|
||||
operator!=(const nsRefPtr<T>& aLhs, decltype(nullptr))
|
||||
{
|
||||
return static_cast<const void*>(aLhs.get()) != reinterpret_cast<const void*>(aRhs);
|
||||
return aLhs.get() != nullptr;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
operator!=(::detail::nsRefPtrZero* aLhs, const nsRefPtr<T>& aRhs)
|
||||
// specifically to allow |0 != smartPtr|
|
||||
operator!=(decltype(nullptr), const nsRefPtr<T>& aRhs)
|
||||
{
|
||||
return reinterpret_cast<const void*>(aLhs) != static_cast<const void*>(aRhs.get());
|
||||
return nullptr != aRhs.get();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -451,15 +451,15 @@ main()
|
||||
else
|
||||
printf("foo1p == foo2p\n");
|
||||
|
||||
printf("\n### Test 7.5: can you compare a |nsCOMPtr| with NULL, 0, nullptr [!=]?\n");
|
||||
if ( foo1p != 0 )
|
||||
printf("foo1p != 0\n");
|
||||
if ( 0 != foo1p )
|
||||
printf("0 != foo1p\n");
|
||||
if ( foo1p == 0 )
|
||||
printf("foo1p == 0\n");
|
||||
if ( 0 == foo1p )
|
||||
printf("0 == foo1p\n");
|
||||
printf("\n### Test 7.5: can you compare a |nsCOMPtr| with nullptr [!=]?\n");
|
||||
if ( foo1p != nullptr )
|
||||
printf("foo1p != nullptr\n");
|
||||
if ( nullptr != foo1p )
|
||||
printf("nullptr != foo1p\n");
|
||||
if ( foo1p == nullptr )
|
||||
printf("foo1p == nullptr\n");
|
||||
if ( nullptr == foo1p )
|
||||
printf("nullptr == foo1p\n");
|
||||
|
||||
|
||||
Foo* raw_foo2p = foo2p.get();
|
||||
@ -500,8 +500,8 @@ main()
|
||||
else
|
||||
printf("foo1p is NULL\n");
|
||||
|
||||
printf("\n### Test 13: numeric pointer test?\n");
|
||||
if ( foo1p == 0 )
|
||||
printf("\n### Test 13: null pointer test?\n");
|
||||
if ( foo1p == nullptr )
|
||||
printf("foo1p is NULL\n");
|
||||
else
|
||||
printf("foo1p is not NULL\n");
|
||||
|
Loading…
Reference in New Issue
Block a user