QJsonValueRef vs QJsonValue

In the Qt JSON implementation in the class, QJsonObjectthere are two operator implementations (documentation here ):

QJsonValue QJsonObject::operator[](const QString & key) const;
QJsonValueRef QJsonObject::operator[](const QString & key);

First of all, what is the advantage of returning QJsonValueRefrather than returning QJsonValue? Secondly, what value will be returned if I just said something like root['time'], where rootis it QJsonObject?

+4
source share
1 answer

You should avoid asking more than one question in the question presented. That being said, here are the answers to your questions:

Returns a reference to the value for the key.

QJsonValueRef, QJsonArray QJsonObject. QJsonValueRef, , QJsonValue. , QJsonArray QJsonObject, .

, , , , , ++.

, , . const, , , , const. const :

> QJsonValue QJsonObject::operator[](const QString & key) const;
                                                          ^^^^^

, . -const, , . , const .

+2

Source: https://habr.com/ru/post/1548159/


All Articles