diff --git a/include/nlohmann/detail/value_t.hpp b/include/nlohmann/detail/value_t.hpp index 0383df06f..a98c4355a 100644 --- a/include/nlohmann/detail/value_t.hpp +++ b/include/nlohmann/detail/value_t.hpp @@ -32,7 +32,7 @@ number_float), because the library distinguishes these three types for numbers: @ref basic_json::number_float_t is used for floating-point numbers or to approximate integers which do not fit in the limits of their respective type. -@sa @ref basic_json::basic_json(const value_t value_type) -- create a JSON +@sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON value with the default value for a given type @since version 1.0.0 diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 086c0f557..5a913c964 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -5746,7 +5746,7 @@ class basic_json iterator result = insert_iterator(pos, cnt, val); for (size_type i = 0; i < cnt; ++i) { - (result + i)->m_parent = this; + (result + static_cast(i))->m_parent = this; } return result; #else @@ -5815,7 +5815,7 @@ class basic_json // insert to array and return iterator #if JSON_DIAGNOSTICS iterator result = insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator); - for (std::size_t i = 0; i < std::distance(first, last); ++i) + for (typename iterator::difference_type i = 0; i < std::distance(first, last); ++i) { (result + i)->m_parent = this; } @@ -5869,7 +5869,7 @@ class basic_json iterator result = insert_iterator(pos, ilist.begin(), ilist.end()); for (std::size_t i = 0; i < size; ++i) { - (result + i)->m_parent = this; + (result + static_cast(i))->m_parent = this; } return result; #else @@ -8391,7 +8391,7 @@ class basic_json }; // wrapper for "add" operation; add value at ptr - const auto operation_add = [this, &result](json_pointer & ptr, basic_json val) + const auto operation_add = [&result](json_pointer & ptr, basic_json val) { // adding to the root of the target document means replacing it if (ptr.empty()) @@ -8489,9 +8489,9 @@ class basic_json for (const auto& val : json_patch) { // wrapper to get a value for an operation - const auto get_value = [this, &val](const std::string & op, - const std::string & member, - bool string_type) -> basic_json & + const auto get_value = [&val](const std::string & op, + const std::string & member, + bool string_type) -> basic_json & { // find value auto it = val.m_value.object->find(member); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index bd79bd6fd..c8a4116f9 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -113,7 +113,7 @@ number_float), because the library distinguishes these three types for numbers: @ref basic_json::number_float_t is used for floating-point numbers or to approximate integers which do not fit in the limits of their respective type. -@sa @ref basic_json::basic_json(const value_t value_type) -- create a JSON +@sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON value with the default value for a given type @since version 1.0.0 @@ -22490,7 +22490,7 @@ class basic_json iterator result = insert_iterator(pos, cnt, val); for (size_type i = 0; i < cnt; ++i) { - (result + i)->m_parent = this; + (result + static_cast(i))->m_parent = this; } return result; #else @@ -22559,7 +22559,7 @@ class basic_json // insert to array and return iterator #if JSON_DIAGNOSTICS iterator result = insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator); - for (std::size_t i = 0; i < std::distance(first, last); ++i) + for (typename iterator::difference_type i = 0; i < std::distance(first, last); ++i) { (result + i)->m_parent = this; } @@ -22613,7 +22613,7 @@ class basic_json iterator result = insert_iterator(pos, ilist.begin(), ilist.end()); for (std::size_t i = 0; i < size; ++i) { - (result + i)->m_parent = this; + (result + static_cast(i))->m_parent = this; } return result; #else @@ -25135,7 +25135,7 @@ class basic_json }; // wrapper for "add" operation; add value at ptr - const auto operation_add = [this, &result](json_pointer & ptr, basic_json val) + const auto operation_add = [&result](json_pointer & ptr, basic_json val) { // adding to the root of the target document means replacing it if (ptr.empty()) @@ -25233,9 +25233,9 @@ class basic_json for (const auto& val : json_patch) { // wrapper to get a value for an operation - const auto get_value = [this, &val](const std::string & op, - const std::string & member, - bool string_type) -> basic_json & + const auto get_value = [&val](const std::string & op, + const std::string & member, + bool string_type) -> basic_json & { // find value auto it = val.m_value.object->find(member); diff --git a/test/src/unit-json_patch.cpp b/test/src/unit-json_patch.cpp index 9d1966f0a..af44e4232 100644 --- a/test/src/unit-json_patch.cpp +++ b/test/src/unit-json_patch.cpp @@ -691,11 +691,10 @@ TEST_CASE("JSON patch") json j; json patch = {"op", "add", "path", "", "value", 1}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.104] parse error: (/0) JSON patch must be an array of objects"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.104] parse error: (/0) JSON patch must be an array of objects"); #else - "[json.exception.parse_error.104] parse error: JSON patch must be an array of objects"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.104] parse error: JSON patch must be an array of objects"); #endif } @@ -704,11 +703,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"foo", "bar"}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation must have member 'op'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation must have member 'op'"); #else - "[json.exception.parse_error.105] parse error: operation must have member 'op'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation must have member 'op'"); #endif } @@ -717,11 +715,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", 1}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation must have string member 'op'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation must have string member 'op'"); #else - "[json.exception.parse_error.105] parse error: operation must have string member 'op'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation must have string member 'op'"); #endif } @@ -730,11 +727,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "foo"}, {"path", ""}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation value 'foo' is invalid"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation value 'foo' is invalid"); #else - "[json.exception.parse_error.105] parse error: operation value 'foo' is invalid"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation value 'foo' is invalid"); #endif } } @@ -746,11 +742,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "add"}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have member 'path'"); #else - "[json.exception.parse_error.105] parse error: operation 'add' must have member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'add' must have member 'path'"); #endif } @@ -759,11 +754,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "add"}, {"path", 1}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have string member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have string member 'path'"); #else - "[json.exception.parse_error.105] parse error: operation 'add' must have string member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'add' must have string member 'path'"); #endif } @@ -772,11 +766,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "add"}, {"path", ""}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have member 'value'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have member 'value'"); #else - "[json.exception.parse_error.105] parse error: operation 'add' must have member 'value'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'add' must have member 'value'"); #endif } @@ -797,11 +790,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "remove"}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'remove' must have member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'remove' must have member 'path'"); #else - "[json.exception.parse_error.105] parse error: operation 'remove' must have member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'remove' must have member 'path'"); #endif } @@ -810,11 +802,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "remove"}, {"path", 1}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'remove' must have string member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'remove' must have string member 'path'"); #else - "[json.exception.parse_error.105] parse error: operation 'remove' must have string member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'remove' must have string member 'path'"); #endif } @@ -853,11 +844,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "replace"}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have member 'path'"); #else - "[json.exception.parse_error.105] parse error: operation 'replace' must have member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'replace' must have member 'path'"); #endif } @@ -866,11 +856,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "replace"}, {"path", 1}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have string member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have string member 'path'"); #else - "[json.exception.parse_error.105] parse error: operation 'replace' must have string member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'replace' must have string member 'path'"); #endif } @@ -879,11 +868,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "replace"}, {"path", ""}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have member 'value'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have member 'value'"); #else - "[json.exception.parse_error.105] parse error: operation 'replace' must have member 'value'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'replace' must have member 'value'"); #endif } @@ -913,13 +901,11 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "move"}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have member 'path'" + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have member 'path'"); #else - "[json.exception.parse_error.105] parse error: operation 'move' must have member 'path'" + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have member 'path'"); #endif - ); } SECTION("non-string 'path'") @@ -927,11 +913,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "move"}, {"path", 1}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have string member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have string member 'path'"); #else - "[json.exception.parse_error.105] parse error: operation 'move' must have string member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have string member 'path'"); #endif } @@ -940,11 +925,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "move"}, {"path", ""}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have member 'from'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have member 'from'"); #else - "[json.exception.parse_error.105] parse error: operation 'move' must have member 'from'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have member 'from'"); #endif } @@ -953,11 +937,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "move"}, {"path", ""}, {"from", 1}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have string member 'from'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have string member 'from'"); #else - "[json.exception.parse_error.105] parse error: operation 'move' must have string member 'from'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have string member 'from'"); #endif } @@ -987,11 +970,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "copy"}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have member 'path'"); #else - "[json.exception.parse_error.105] parse error: operation 'copy' must have member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have member 'path'"); #endif } @@ -1000,11 +982,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "copy"}, {"path", 1}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have string member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have string member 'path'"); #else - "[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'path'"); #endif } @@ -1013,11 +994,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "copy"}, {"path", ""}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have member 'from'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have member 'from'"); #else - "[json.exception.parse_error.105] parse error: operation 'copy' must have member 'from'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have member 'from'"); #endif } @@ -1026,11 +1006,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "copy"}, {"path", ""}, {"from", 1}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have string member 'from'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have string member 'from'"); #else - "[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'from'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'from'"); #endif } @@ -1060,11 +1039,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "test"}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have member 'path'"); #else - "[json.exception.parse_error.105] parse error: operation 'test' must have member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'test' must have member 'path'"); #endif } @@ -1073,11 +1051,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "test"}, {"path", 1}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have string member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have string member 'path'"); #else - "[json.exception.parse_error.105] parse error: operation 'test' must have string member 'path'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'test' must have string member 'path'"); #endif } @@ -1086,11 +1063,10 @@ TEST_CASE("JSON patch") json j; json patch = {{{"op", "test"}, {"path", ""}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); - CHECK_THROWS_WITH(j.patch(patch), #if JSON_DIAGNOSTICS - "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have member 'value'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have member 'value'"); #else - "[json.exception.parse_error.105] parse error: operation 'test' must have member 'value'"); + CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'test' must have member 'value'"); #endif } }