1
0
mirror of https://github.com/nlohmann/json synced 2024-11-10 14:30:08 +00:00

Make json_pointer::back const (resolves #1764)

This commit is contained in:
christian 2019-10-01 00:57:27 +02:00
parent 99d7518d21
commit 7476f5ee0c
3 changed files with 6 additions and 2 deletions

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()))
{

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()))
{

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());