I'm not sure if I should bother at all because it's not any safety critical application but I'm just curious and can't figure it out myself: will the compiler apply RVO for the following method?
QJsonObject MyClass::buildObject(const QVector2D& position, const QString& id) const
{
QJsonObject retObject {
{"Position", QJsonArray{position.x(), position.y()}},
};
if (!id.isNull() && !id.isEmpty())
{
retObject.insert("Id", id);
}
return retObject;
}
The QJsonObject class does not implement the move constructor nor the move assignment operator. I'm using GCC 5.4 (--std=c++14) via Qt 5.9 under Ubuntu.