Merge pull request #1769 from chris0x44/json_pointer

Make json_pointer::back const (resolves #1764)
This commit is contained in:
Niels Lohmann authored and GitHub committed 2019-10-03 10:35:34 +02:00
commit dae0fe79af
3 files changed
+6 -2

No files matched your search

+1 -1
View File
@@ -267,7 +267,7 @@ class json_pointer
@since version 3.6.0
*/
const std::string& back()
const std::string& back() const
{
if (JSON_HEDLEY_UNLIKELY(empty()))
{
+1 -1
View File
@@ -10232,7 +10232,7 @@ class json_pointer
@since version 3.6.0
*/
const std::string& back()
const std::string& back() const
{
if (JSON_HEDLEY_UNLIKELY(empty()))
{
+4
View File
@@ -559,6 +559,10 @@ TEST_CASE("JSON pointers")
CHECK(!ptr.empty());
CHECK(j[ptr] == j["answer"]["everything"]);
// check access via const pointer
const auto cptr = ptr;
CHECK(cptr.back() == "everything");
ptr.pop_back();
ptr.pop_back();
CHECK(ptr.empty());