From 699e0a923c11d6a8426c841852677177de7075d7 Mon Sep 17 00:00:00 2001 From: dota17 Date: Wed, 26 Feb 2020 13:44:08 +0800 Subject: [PATCH] fix typo in examples --- doc/examples/at__object_t_key_type_const.cpp | 2 +- doc/examples/begin.cpp | 2 +- doc/examples/cbegin.cpp | 2 +- doc/examples/cend.cpp | 2 +- doc/examples/contains_json_pointer.cpp | 1 - doc/examples/count.cpp | 2 +- doc/examples/end.cpp | 2 +- doc/examples/erase__IteratorType.cpp | 2 +- doc/examples/erase__IteratorType_IteratorType.cpp | 2 +- doc/examples/erase__key_type.cpp | 2 +- doc/examples/erase__size_type.cpp | 2 +- doc/examples/operatorarray__size_type_const.cpp | 2 +- 12 files changed, 11 insertions(+), 12 deletions(-) diff --git a/doc/examples/at__object_t_key_type_const.cpp b/doc/examples/at__object_t_key_type_const.cpp index 56ce5766..e5244f3f 100644 --- a/doc/examples/at__object_t_key_type_const.cpp +++ b/doc/examples/at__object_t_key_type_const.cpp @@ -6,7 +6,7 @@ using json = nlohmann::json; int main() { // create JSON object - json object = + const json object = { {"the good", "il buono"}, {"the bad", "il cattivo"}, diff --git a/doc/examples/begin.cpp b/doc/examples/begin.cpp index 42710d15..654835b0 100644 --- a/doc/examples/begin.cpp +++ b/doc/examples/begin.cpp @@ -8,7 +8,7 @@ int main() // create an array value json array = {1, 2, 3, 4, 5}; - // get am iterator to the first element + // get an iterator to the first element json::iterator it = array.begin(); // serialize the element that the iterator points to diff --git a/doc/examples/cbegin.cpp b/doc/examples/cbegin.cpp index 3226fd21..bed2b372 100644 --- a/doc/examples/cbegin.cpp +++ b/doc/examples/cbegin.cpp @@ -8,7 +8,7 @@ int main() // create an array value const json array = {1, 2, 3, 4, 5}; - // get am iterator to the first element + // get an iterator to the first element json::const_iterator it = array.cbegin(); // serialize the element that the iterator points to diff --git a/doc/examples/cend.cpp b/doc/examples/cend.cpp index 9d7978d5..3050f500 100644 --- a/doc/examples/cend.cpp +++ b/doc/examples/cend.cpp @@ -8,7 +8,7 @@ int main() // create an array value json array = {1, 2, 3, 4, 5}; - // get am iterator to one past the last element + // get an iterator to one past the last element json::const_iterator it = array.cend(); // decrement the iterator to point to the last element diff --git a/doc/examples/contains_json_pointer.cpp b/doc/examples/contains_json_pointer.cpp index ed45fcee..5375a435 100644 --- a/doc/examples/contains_json_pointer.cpp +++ b/doc/examples/contains_json_pointer.cpp @@ -14,7 +14,6 @@ int main() std::cout << std::boolalpha << j.contains("/number"_json_pointer) << '\n' << j.contains("/string"_json_pointer) << '\n' - << j.contains("/string"_json_pointer) << '\n' << j.contains("/array"_json_pointer) << '\n' << j.contains("/array/1"_json_pointer) << '\n' << j.contains("/array/-"_json_pointer) << '\n' diff --git a/doc/examples/count.cpp b/doc/examples/count.cpp index 0ea19b6c..a8d54b9d 100644 --- a/doc/examples/count.cpp +++ b/doc/examples/count.cpp @@ -8,7 +8,7 @@ int main() // create a JSON object json j_object = {{"one", 1}, {"two", 2}}; - // call find + // call count() auto count_two = j_object.count("two"); auto count_three = j_object.count("three"); diff --git a/doc/examples/end.cpp b/doc/examples/end.cpp index 5a5b6e72..47beedb7 100644 --- a/doc/examples/end.cpp +++ b/doc/examples/end.cpp @@ -8,7 +8,7 @@ int main() // create an array value json array = {1, 2, 3, 4, 5}; - // get am iterator to one past the last element + // get an iterator to one past the last element json::iterator it = array.end(); // decrement the iterator to point to the last element diff --git a/doc/examples/erase__IteratorType.cpp b/doc/examples/erase__IteratorType.cpp index bf5d3dd4..f0d4ec6f 100644 --- a/doc/examples/erase__IteratorType.cpp +++ b/doc/examples/erase__IteratorType.cpp @@ -13,7 +13,7 @@ int main() json j_array = {1, 2, 4, 8, 16}; json j_string = "Hello, world"; - // call erase + // call erase() j_boolean.erase(j_boolean.begin()); j_number_integer.erase(j_number_integer.begin()); j_number_float.erase(j_number_float.begin()); diff --git a/doc/examples/erase__IteratorType_IteratorType.cpp b/doc/examples/erase__IteratorType_IteratorType.cpp index 7cddac6a..392511ff 100644 --- a/doc/examples/erase__IteratorType_IteratorType.cpp +++ b/doc/examples/erase__IteratorType_IteratorType.cpp @@ -13,7 +13,7 @@ int main() json j_array = {1, 2, 4, 8, 16}; json j_string = "Hello, world"; - // call erase + // call erase() j_boolean.erase(j_boolean.begin(), j_boolean.end()); j_number_integer.erase(j_number_integer.begin(), j_number_integer.end()); j_number_float.erase(j_number_float.begin(), j_number_float.end()); diff --git a/doc/examples/erase__key_type.cpp b/doc/examples/erase__key_type.cpp index 40c75511..2fd84c86 100644 --- a/doc/examples/erase__key_type.cpp +++ b/doc/examples/erase__key_type.cpp @@ -8,7 +8,7 @@ int main() // create a JSON object json j_object = {{"one", 1}, {"two", 2}}; - // call erase + // call erase() auto count_one = j_object.erase("one"); auto count_three = j_object.erase("three"); diff --git a/doc/examples/erase__size_type.cpp b/doc/examples/erase__size_type.cpp index b6d7b011..81006238 100644 --- a/doc/examples/erase__size_type.cpp +++ b/doc/examples/erase__size_type.cpp @@ -8,7 +8,7 @@ int main() // create a JSON array json j_array = {0, 1, 2, 3, 4, 5}; - // call erase + // call erase() j_array.erase(2); // print values diff --git a/doc/examples/operatorarray__size_type_const.cpp b/doc/examples/operatorarray__size_type_const.cpp index 1bd88bc1..d56fa0a4 100644 --- a/doc/examples/operatorarray__size_type_const.cpp +++ b/doc/examples/operatorarray__size_type_const.cpp @@ -6,7 +6,7 @@ using json = nlohmann::json; int main() { // create JSON array - json array = {"first", "2nd", "third", "fourth"}; + const json array = {"first", "2nd", "third", "fourth"}; // output element at index 2 (third element) std::cout << array.at(2) << '\n';