Core/ObjectRef: Add comparison operators
Former-commit-id: 64e1994a16df92191d22dd3d6cd9b249707c74f7 [formerly b77b0afef5c0b720b5660893adb3246c97e55797] Former-commit-id: b9dbc04e30c52f8414637b89b52028103022bead
This commit is contained in:
parent
e52656bed8
commit
84039cd78a
|
|
@ -44,8 +44,33 @@ namespace Nz
|
|||
T* m_object;
|
||||
};
|
||||
|
||||
template<typename T> struct PointedType<ObjectRef<T>> {typedef T type;};
|
||||
template<typename T> struct PointedType<ObjectRef<T> const> {typedef T type;};
|
||||
template<typename T> bool operator==(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator==(const T& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator==(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
template<typename T> bool operator!=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator!=(const T& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator!=(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
template<typename T> bool operator<(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator<(const T& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator<(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
template<typename T> bool operator<=(const ObjectRef<T>, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator<=(const T& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator<=(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
template<typename T> bool operator>(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator>(const T& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator>(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
template<typename T> bool operator>=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator>=(const T& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator>=(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
|
||||
template<typename T> struct PointedType<ObjectRef<T>> { typedef T type; };
|
||||
template<typename T> struct PointedType<ObjectRef<T> const> { typedef T type; };
|
||||
}
|
||||
|
||||
#include <Nazara/Core/ObjectRef.inl>
|
||||
|
|
|
|||
|
|
@ -245,6 +245,241 @@ namespace Nz
|
|||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is equal to the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator==(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return lhs.Get() == rhs.Get();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the object is equal to the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first Object to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator==(const T& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return &lhs == rhs.Get();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the object handle is equal to the second object
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second Object to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator==(const ObjectRef<T>& lhs, const T& rhs)
|
||||
{
|
||||
return lhs.Get() == &rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is equal to the second object handle
|
||||
* \return false if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator!=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the object is equal to the second object handle
|
||||
* \return false if it is the case
|
||||
*
|
||||
* \param first Object to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator!=(const T& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the object handle is equal to the second object
|
||||
* \return false if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second Object to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator!=(const ObjectRef<T>& lhs, const T& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is less than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator<(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return lhs.m_object < rhs.m_object;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is less than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator<(const T& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return &lhs < rhs.m_object;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is less than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator<(const ObjectRef<T>& lhs, const T& rhs)
|
||||
{
|
||||
return lhs.m_object < &rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is less or equal than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator<=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is less or equal than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator<=(const T& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is less or equal than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator<=(const ObjectRef<T>& lhs, const T& rhs)
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is greather than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator>(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is greather than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator>(const T& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is greather than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator>(const ObjectRef<T>& lhs, const T& rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator>=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator>=(const T& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator>=(const ObjectRef<T>& lhs, const T& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
}
|
||||
|
||||
namespace std
|
||||
|
|
|
|||
Loading…
Reference in New Issue