Skip to content

Commit ccd077f

Browse files
Radoslav Atanasovcdunn2001
Radoslav Atanasov
authored andcommitted
Fix MSVC 15.9 (2017) warning C4866
by changing operator[] param type from JSONCPP_STRING to const JSONCPP_STRING& for CharReaderBuilder and StreamWriterBuilder (as it is already in Value). https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c4866?view=vs-2017
1 parent 4abf4ec commit ccd077f

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

include/json/reader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ class JSON_API CharReaderBuilder : public CharReader::Factory {
358358

359359
/** A simple way to update a specific setting.
360360
*/
361-
Value& operator[](JSONCPP_STRING key);
361+
Value& operator[](const JSONCPP_STRING& key);
362362

363363
/** Called by ctor, but you can use this to reset settings_.
364364
* \pre 'settings' != NULL (but Json::null is fine)

include/json/writer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
132132
bool validate(Json::Value* invalid) const;
133133
/** A simple way to update a specific setting.
134134
*/
135-
Value& operator[](JSONCPP_STRING key);
135+
Value& operator[](const JSONCPP_STRING& key);
136136

137137
/** Called by ctor, but you can use this to reset settings_.
138138
* \pre 'settings' != NULL (but Json::null is fine)

src/lib_json/json_reader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ bool CharReaderBuilder::validate(Json::Value* invalid) const {
19691969
}
19701970
return 0u == inv.size();
19711971
}
1972-
Value& CharReaderBuilder::operator[](JSONCPP_STRING key) {
1972+
Value& CharReaderBuilder::operator[](const JSONCPP_STRING& key) {
19731973
return settings_[key];
19741974
}
19751975
// static

src/lib_json/json_value.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ const Value& Value::operator[](const char* key) const {
11451145
return nullSingleton();
11461146
return *found;
11471147
}
1148-
Value const& Value::operator[](JSONCPP_STRING const& key) const {
1148+
Value const& Value::operator[](const JSONCPP_STRING& key) const {
11491149
Value const* found = find(key.data(), key.data() + key.length());
11501150
if (!found)
11511151
return nullSingleton();

src/lib_json/json_writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ bool StreamWriterBuilder::validate(Json::Value* invalid) const {
12311231
}
12321232
return 0u == inv.size();
12331233
}
1234-
Value& StreamWriterBuilder::operator[](JSONCPP_STRING key) {
1234+
Value& StreamWriterBuilder::operator[](const JSONCPP_STRING& key) {
12351235
return settings_[key];
12361236
}
12371237
// static

0 commit comments

Comments
 (0)