Bug 1196050 - Replace NSCAP_Zero usage with decltype(nullptr). r=froydnj

This commit is contained in:
Xidorn Quan 2015-08-20 10:30:10 +10:00
parent c4c2164df2
commit 6f7cb57689
3 changed files with 35 additions and 53 deletions

View File

@ -417,37 +417,33 @@ operator!=( U* lhs, const nsHtml5RefPtr<T>& rhs )
template <class T>
inline
bool
operator==( const nsHtml5RefPtr<T>& lhs, NSCAP_Zero* rhs )
// specifically to allow |smartPtr == 0|
operator==( const nsHtml5RefPtr<T>& lhs, decltype(nullptr) )
{
return static_cast<const void*>(lhs.get()) == reinterpret_cast<const void*>(rhs);
return lhs.get() == nullptr;
}
template <class T>
inline
bool
operator==( NSCAP_Zero* lhs, const nsHtml5RefPtr<T>& rhs )
// specifically to allow |0 == smartPtr|
operator==( decltype(nullptr), const nsHtml5RefPtr<T>& rhs )
{
return reinterpret_cast<const void*>(lhs) == static_cast<const void*>(rhs.get());
return nullptr == rhs.get();
}
template <class T>
inline
bool
operator!=( const nsHtml5RefPtr<T>& lhs, NSCAP_Zero* rhs )
// specifically to allow |smartPtr != 0|
operator!=( const nsHtml5RefPtr<T>& lhs, decltype(nullptr) )
{
return static_cast<const void*>(lhs.get()) != reinterpret_cast<const void*>(rhs);
return lhs.get() != nullptr;
}
template <class T>
inline
bool
operator!=( NSCAP_Zero* lhs, const nsHtml5RefPtr<T>& rhs )
// specifically to allow |0 != smartPtr|
operator!=( decltype(nullptr), const nsHtml5RefPtr<T>& rhs )
{
return reinterpret_cast<const void*>(lhs) != static_cast<const void*>(rhs.get());
return nullptr != rhs.get();
}
#endif // !defined(nsHtml5RefPtr_h)

View File

@ -414,38 +414,34 @@ operator!=(U* aLhs, const nsAutoPtr<T>& aRhs)
// Comparing an |nsAutoPtr| to |0|
// Comparing an |nsAutoPtr| to |nullptr|
template <class T>
inline bool
operator==(const nsAutoPtr<T>& aLhs, NSCAP_Zero* aRhs)
// specifically to allow |smartPtr == 0|
operator==(const nsAutoPtr<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==(NSCAP_Zero* aLhs, const nsAutoPtr<T>& aRhs)
// specifically to allow |0 == smartPtr|
operator==(decltype(nullptr), const nsAutoPtr<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 nsAutoPtr<T>& aLhs, NSCAP_Zero* aRhs)
// specifically to allow |smartPtr != 0|
operator!=(const nsAutoPtr<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!=(NSCAP_Zero* aLhs, const nsAutoPtr<T>& aRhs)
// specifically to allow |0 != smartPtr|
operator!=(decltype(nullptr), const nsAutoPtr<T>& aRhs)
{
return reinterpret_cast<const void*>(aLhs) != static_cast<const void*>(aRhs.get());
return nullptr != aRhs.get();
}
@ -766,38 +762,34 @@ operator!=(U* aLhs, const nsAutoArrayPtr<T>& aRhs)
// Comparing an |nsAutoArrayPtr| to |0|
// Comparing an |nsAutoArrayPtr| to |nullptr|
template <class T>
inline bool
operator==(const nsAutoArrayPtr<T>& aLhs, NSCAP_Zero* aRhs)
// specifically to allow |smartPtr == 0|
operator==(const nsAutoArrayPtr<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==(NSCAP_Zero* aLhs, const nsAutoArrayPtr<T>& aRhs)
// specifically to allow |0 == smartPtr|
operator==(decltype(nullptr), const nsAutoArrayPtr<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 nsAutoArrayPtr<T>& aLhs, NSCAP_Zero* aRhs)
// specifically to allow |smartPtr != 0|
operator!=(const nsAutoArrayPtr<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!=(NSCAP_Zero* aLhs, const nsAutoArrayPtr<T>& aRhs)
// specifically to allow |0 != smartPtr|
operator!=(decltype(nullptr), const nsAutoArrayPtr<T>& aRhs)
{
return reinterpret_cast<const void*>(aLhs) != static_cast<const void*>(aRhs.get());
return nullptr != aRhs.get();
}

View File

@ -1350,40 +1350,34 @@ operator!=(U* aLhs, const nsCOMPtr<T>& aRhs)
// Comparing an |nsCOMPtr| to |0|
// Comparing an |nsCOMPtr| to |nullptr|
class NSCAP_Zero;
// Specifically to allow |smartPtr == 0|.
template<class T>
inline bool
operator==(const nsCOMPtr<T>& aLhs, NSCAP_Zero* aRhs)
operator==(const nsCOMPtr<T>& aLhs, decltype(nullptr))
{
return static_cast<const void*>(aLhs.get()) == reinterpret_cast<const void*>(aRhs);
return aLhs.get() == nullptr;
}
// Specifically to allow |0 == smartPtr|.
template<class T>
inline bool
operator==(NSCAP_Zero* aLhs, const nsCOMPtr<T>& aRhs)
operator==(decltype(nullptr), const nsCOMPtr<T>& aRhs)
{
return reinterpret_cast<const void*>(aLhs) == static_cast<const void*>(aRhs.get());
return nullptr == aRhs.get();
}
// Specifically to allow |smartPtr != 0|.
template<class T>
inline bool
operator!=(const nsCOMPtr<T>& aLhs, NSCAP_Zero* aRhs)
operator!=(const nsCOMPtr<T>& aLhs, decltype(nullptr))
{
return static_cast<const void*>(aLhs.get()) != reinterpret_cast<const void*>(aRhs);
return aLhs.get() != nullptr;
}
// Specifically to allow |0 != smartPtr|.
template<class T>
inline bool
operator!=(NSCAP_Zero* aLhs, const nsCOMPtr<T>& aRhs)
operator!=(decltype(nullptr), const nsCOMPtr<T>& aRhs)
{
return reinterpret_cast<const void*>(aLhs) != static_cast<const void*>(aRhs.get());
return nullptr != aRhs.get();
}