mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Backed out changeset 20c6f74296e2 (bug 1195154) for causing Bug 1196115
--HG-- extra : rebase_source : 59356f3ff488b4000e4f3034f9c676d4afe8b49f
This commit is contained in:
parent
d6b3882365
commit
0005d3bf06
@ -549,34 +549,42 @@ operator!=(U* aLhs, const nsRefPtr<T>& aRhs)
|
|||||||
return const_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get());
|
return const_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comparing an |nsRefPtr| to |nullptr|
|
namespace detail {
|
||||||
|
class nsRefPtrZero;
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
// Comparing an |nsRefPtr| to |0|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline bool
|
inline bool
|
||||||
operator==(const nsRefPtr<T>& aLhs, decltype(nullptr))
|
operator==(const nsRefPtr<T>& aLhs, ::detail::nsRefPtrZero* aRhs)
|
||||||
|
// specifically to allow |smartPtr == 0|
|
||||||
{
|
{
|
||||||
return aLhs.get() == nullptr;
|
return static_cast<const void*>(aLhs.get()) == reinterpret_cast<const void*>(aRhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline bool
|
inline bool
|
||||||
operator==(decltype(nullptr), const nsRefPtr<T>& aRhs)
|
operator==(::detail::nsRefPtrZero* aLhs, const nsRefPtr<T>& aRhs)
|
||||||
|
// specifically to allow |0 == smartPtr|
|
||||||
{
|
{
|
||||||
return nullptr == aRhs.get();
|
return reinterpret_cast<const void*>(aLhs) == static_cast<const void*>(aRhs.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline bool
|
inline bool
|
||||||
operator!=(const nsRefPtr<T>& aLhs, decltype(nullptr))
|
operator!=(const nsRefPtr<T>& aLhs, ::detail::nsRefPtrZero* aRhs)
|
||||||
|
// specifically to allow |smartPtr != 0|
|
||||||
{
|
{
|
||||||
return aLhs.get() != nullptr;
|
return static_cast<const void*>(aLhs.get()) != reinterpret_cast<const void*>(aRhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline bool
|
inline bool
|
||||||
operator!=(decltype(nullptr), const nsRefPtr<T>& aRhs)
|
operator!=(::detail::nsRefPtrZero* aLhs, const nsRefPtr<T>& aRhs)
|
||||||
|
// specifically to allow |0 != smartPtr|
|
||||||
{
|
{
|
||||||
return nullptr != aRhs.get();
|
return reinterpret_cast<const void*>(aLhs) != static_cast<const void*>(aRhs.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -451,15 +451,15 @@ main()
|
|||||||
else
|
else
|
||||||
printf("foo1p == foo2p\n");
|
printf("foo1p == foo2p\n");
|
||||||
|
|
||||||
printf("\n### Test 7.5: can you compare a |nsCOMPtr| with nullptr [!=]?\n");
|
printf("\n### Test 7.5: can you compare a |nsCOMPtr| with NULL, 0, nullptr [!=]?\n");
|
||||||
if ( foo1p != nullptr )
|
if ( foo1p != 0 )
|
||||||
printf("foo1p != nullptr\n");
|
printf("foo1p != 0\n");
|
||||||
if ( nullptr != foo1p )
|
if ( 0 != foo1p )
|
||||||
printf("nullptr != foo1p\n");
|
printf("0 != foo1p\n");
|
||||||
if ( foo1p == nullptr )
|
if ( foo1p == 0 )
|
||||||
printf("foo1p == nullptr\n");
|
printf("foo1p == 0\n");
|
||||||
if ( nullptr == foo1p )
|
if ( 0 == foo1p )
|
||||||
printf("nullptr == foo1p\n");
|
printf("0 == foo1p\n");
|
||||||
|
|
||||||
|
|
||||||
Foo* raw_foo2p = foo2p.get();
|
Foo* raw_foo2p = foo2p.get();
|
||||||
@ -500,8 +500,8 @@ main()
|
|||||||
else
|
else
|
||||||
printf("foo1p is NULL\n");
|
printf("foo1p is NULL\n");
|
||||||
|
|
||||||
printf("\n### Test 13: null pointer test?\n");
|
printf("\n### Test 13: numeric pointer test?\n");
|
||||||
if ( foo1p == nullptr )
|
if ( foo1p == 0 )
|
||||||
printf("foo1p is NULL\n");
|
printf("foo1p is NULL\n");
|
||||||
else
|
else
|
||||||
printf("foo1p is not NULL\n");
|
printf("foo1p is not NULL\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user