mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
refs #345 Symmetric equality operators complete the original implementation of CValueObjectStdTuple.
This commit is contained in:
@@ -60,23 +60,6 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Equal?
|
|
||||||
*/
|
|
||||||
bool CStatusMessage::operator ==(const CStatusMessage &other) const
|
|
||||||
{
|
|
||||||
if (this == &other) return true;
|
|
||||||
return TupleConverter<CStatusMessage>::toTuple(*this) == TupleConverter<CStatusMessage>::toTuple(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Unequal?
|
|
||||||
*/
|
|
||||||
bool CStatusMessage::operator !=(const CStatusMessage &other) const
|
|
||||||
{
|
|
||||||
return !((*this) == other);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Conversion
|
* Conversion
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -66,12 +66,6 @@ namespace BlackMisc
|
|||||||
//! \sa QtMessageHandler
|
//! \sa QtMessageHandler
|
||||||
void toQtLogTriple(QtMsgType *o_type, QString *o_category, QString *o_message) const;
|
void toQtLogTriple(QtMsgType *o_type, QString *o_category, QString *o_message) const;
|
||||||
|
|
||||||
//! Equal operator ==
|
|
||||||
bool operator ==(const CStatusMessage &other) const;
|
|
||||||
|
|
||||||
//! Unequal operator !=
|
|
||||||
bool operator !=(const CStatusMessage &other) const;
|
|
||||||
|
|
||||||
//! Message category
|
//! Message category
|
||||||
const CLogCategoryList &getCategories() const { return this->m_categories; }
|
const CLogCategoryList &getCategories() const { return this->m_categories; }
|
||||||
|
|
||||||
|
|||||||
@@ -278,6 +278,15 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
template <class Derived> class CValueObjectStdTuple : public CValueObject
|
template <class Derived> class CValueObjectStdTuple : public CValueObject
|
||||||
{
|
{
|
||||||
|
friend bool operator ==(const Derived &a, const Derived &b)
|
||||||
|
{
|
||||||
|
return equals(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
friend bool operator !=(const Derived &a, const Derived &b)
|
||||||
|
{
|
||||||
|
return !(a == b);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! \copydoc CValueObject::getValueHash()
|
//! \copydoc CValueObject::getValueHash()
|
||||||
@@ -362,6 +371,14 @@ namespace BlackMisc
|
|||||||
private:
|
private:
|
||||||
const Derived *derived() const { return static_cast<const Derived *>(this); }
|
const Derived *derived() const { return static_cast<const Derived *>(this); }
|
||||||
Derived *derived() { return static_cast<Derived *>(this); }
|
Derived *derived() { return static_cast<Derived *>(this); }
|
||||||
|
|
||||||
|
// Friend functions are implemented in terms of private static member functions, because
|
||||||
|
// friendship is not transitive: friends of CValueObjectStdTuple are not friends of TupleConverter.
|
||||||
|
static bool equals(const Derived &a, const Derived &b)
|
||||||
|
{
|
||||||
|
if (&a == &b) { return true; }
|
||||||
|
return TupleConverter<Derived>::toMetaTuple(a) == TupleConverter<Derived>::toMetaTuple(b);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
Reference in New Issue
Block a user