Operator function templates, using std::enable_if to match only classes

derived from CStreamable, for streaming to/from QtDBusArgument, avoiding
the unrelated operator function template for streaming Container<T>
defined by Qt, by being a better match in overload resolution.
This commit is contained in:
Mathew Sutcliffe
2013-08-26 21:15:59 +01:00
parent ea4d0dedbb
commit 7117545fd6
4 changed files with 28 additions and 84 deletions

View File

@@ -21,34 +21,6 @@ class CMatrix3x1;
*/
template <class ImplVector> class CVector3DBase : public CStreamable
{
/*!
* \brief Unmarshalling operator >>, DBus to object
* \param argument
* \param uc
* \return
*/
friend const QDBusArgument &operator>>(const QDBusArgument &argument, ImplVector &uc)
{
// If I do not have the method here, DBus metasystem tries to stream against
// a container: inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<T> &list)
// Once someone solves this, this methods should go and the
// CStreamable signature should be used
CStreamable &sf = uc;
return argument >> sf;
}
/*!
* \brief Marshalling operator <<, object to DBus
* \param argument
* \param pq
* \return
*/
friend QDBusArgument &operator<<(QDBusArgument &argument, const ImplVector &uc)
{
const CStreamable &sf = uc;
return argument << sf;
}
private:
/*!
* \brief Easy access to derived class (CRTP template parameter)