Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
5.4.1
-
None
-
Ubuntu 14.04 x64
gcc 4.8.2
Qt 5.4.1
Description
I have a QJsonArray that only contains strings. When I try to use std::sort on the array, I get a compiler error message stating it could not find a swap function with the signature swap(QJsonValueRef, QJsonValueRef).
Example:
QJsonArray array; array.append(QString("v1")); array.append(QString("v2")); std::sort(array.begin(), array.end(), [](QJsonValue &v1, QJsonValue &v2){ return v1.toString() < v2.toString(); });
Gcc Error Message:
no matching function for call to 'swap(QJsonValueRef, QJsonValueRef)' swap(*__a, *__b);
My work around was to write the following code in a global header file:
inline void swap(QJsonValueRef v1, QJsonValueRef v2) { QJsonValue temp(v1); v1 = QJsonValue(v2); v2 = temp; }
Ideally, this function should live below the definition of QJsonValueRef.