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
diff --git a/include/json/reader.h b/include/json/reader.h
index b700d95..9a7fba2 100644
--- a/include/json/reader.h
+++ b/include/json/reader.h
@@ -358,7 +358,7 @@
/** A simple way to update a specific setting.
*/
- Value& operator[](JSONCPP_STRING key);
+ Value& operator[](const JSONCPP_STRING& key);
/** Called by ctor, but you can use this to reset settings_.
* \pre 'settings' != NULL (but Json::null is fine)
diff --git a/include/json/writer.h b/include/json/writer.h
index c92d26b..d70ca1c 100644
--- a/include/json/writer.h
+++ b/include/json/writer.h
@@ -132,7 +132,7 @@
bool validate(Json::Value* invalid) const;
/** A simple way to update a specific setting.
*/
- Value& operator[](JSONCPP_STRING key);
+ Value& operator[](const JSONCPP_STRING& key);
/** Called by ctor, but you can use this to reset settings_.
* \pre 'settings' != NULL (but Json::null is fine)
diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp
index 264df0b..5a945af 100644
--- a/src/lib_json/json_reader.cpp
+++ b/src/lib_json/json_reader.cpp
@@ -1969,7 +1969,7 @@
}
return 0u == inv.size();
}
-Value& CharReaderBuilder::operator[](JSONCPP_STRING key) {
+Value& CharReaderBuilder::operator[](const JSONCPP_STRING& key) {
return settings_[key];
}
// static
diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp
index 2e7602e..6bb73c0 100644
--- a/src/lib_json/json_value.cpp
+++ b/src/lib_json/json_value.cpp
@@ -1145,7 +1145,7 @@
return nullSingleton();
return *found;
}
-Value const& Value::operator[](JSONCPP_STRING const& key) const {
+Value const& Value::operator[](const JSONCPP_STRING& key) const {
Value const* found = find(key.data(), key.data() + key.length());
if (!found)
return nullSingleton();
diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp
index 60d3251..b93e92f 100644
--- a/src/lib_json/json_writer.cpp
+++ b/src/lib_json/json_writer.cpp
@@ -1231,7 +1231,7 @@
}
return 0u == inv.size();
}
-Value& StreamWriterBuilder::operator[](JSONCPP_STRING key) {
+Value& StreamWriterBuilder::operator[](const JSONCPP_STRING& key) {
return settings_[key];
}
// static