Core/ObjectRef: Add comparison operators
Former-commit-id: 74028870996d72cb0fa707c27342c892168f8fe4 [formerly 0eb6bb74988e76213f9e534a376b1c0af14a7c92] Former-commit-id: 006289f7a338a263f91832039850751e685b9ceb
This commit is contained in:
parent
fbc963402c
commit
daf1dadda0
|
|
@ -44,8 +44,33 @@ namespace Nz
|
||||||
T* m_object;
|
T* m_object;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct PointedType<ObjectRef<T>> {typedef T type;};
|
template<typename T> bool operator==(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs);
|
||||||
template<typename T> struct PointedType<ObjectRef<T> const> {typedef T type;};
|
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>
|
#include <Nazara/Core/ObjectRef.inl>
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,241 @@ namespace Nz
|
||||||
|
|
||||||
return *this;
|
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
|
namespace std
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue