mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 12:09:36 +00:00
Add more nullptr_t operators
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
namespace PortabilityLayer
|
namespace PortabilityLayer
|
||||||
{
|
{
|
||||||
struct MMHandleBlock;
|
struct MMHandleBlock;
|
||||||
@@ -47,6 +49,9 @@ public:
|
|||||||
bool operator==(T** other) const;
|
bool operator==(T** other) const;
|
||||||
bool operator!=(T** other) const;
|
bool operator!=(T** other) const;
|
||||||
|
|
||||||
|
bool operator==(std::nullptr_t) const;
|
||||||
|
bool operator!=(std::nullptr_t) const;
|
||||||
|
|
||||||
static THandle<T> NullPtr();
|
static THandle<T> NullPtr();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -114,17 +119,33 @@ inline bool THandle<T>::operator!=(const THandle<T> &other) const
|
|||||||
template<class T>
|
template<class T>
|
||||||
inline bool THandle<T>::operator==(T** other) const
|
inline bool THandle<T>::operator==(T** other) const
|
||||||
{
|
{
|
||||||
|
if (other == nullptr)
|
||||||
|
return m_hdl == nullptr;
|
||||||
return static_cast<void*>(&m_hdl->m_contents) == static_cast<void*>(other);
|
return static_cast<void*>(&m_hdl->m_contents) == static_cast<void*>(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool THandle<T>::operator!=(T** other) const
|
inline bool THandle<T>::operator!=(T** other) const
|
||||||
{
|
{
|
||||||
|
if (other == nullptr)
|
||||||
|
return m_hdl != nullptr;
|
||||||
return static_cast<void*>(&m_hdl->m_contents) != static_cast<void*>(other);
|
return static_cast<void*>(&m_hdl->m_contents) != static_cast<void*>(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
THandle<T> THandle<T>::NullPtr()
|
inline bool THandle<T>::operator==(std::nullptr_t) const
|
||||||
|
{
|
||||||
|
return m_hdl == nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline bool THandle<T>::operator!=(std::nullptr_t) const
|
||||||
|
{
|
||||||
|
return m_hdl != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline THandle<T> THandle<T>::NullPtr()
|
||||||
{
|
{
|
||||||
return THandle<T>(static_cast<PortabilityLayer::MMHandleBlock *>(nullptr));
|
return THandle<T>(static_cast<PortabilityLayer::MMHandleBlock *>(nullptr));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user