Advertisement
Dijuna

template

Jan 26th, 2017
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     template <typename T> QByteArray listToArray(const QList<T>& list) {
  2.         QByteArray out;
  3.         QDataStream stream(&out, QIODevice::WriteOnly);
  4.         for (const T& t : list) {
  5.             stream << t;
  6.         }
  7.         return out;
  8.     }
  9.     template <typename T> template <> QByteArray listToArray<QList<T>>(const QList<T>& list) {
  10.         QByteArray out;
  11.         QDataStream stream(&out, QIODevice::WriteOnly);
  12.         for (const T& t : list) {
  13.             stream << listToArray(t);
  14.         }
  15.         return out;
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement