Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
7476f5ee
Commit
7476f5ee
authored
Oct 01, 2019
by
christian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make json_pointer::back const (resolves #1764)
parent
99d7518d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
2 deletions
+6
-2
include/nlohmann/detail/json_pointer.hpp
include/nlohmann/detail/json_pointer.hpp
+1
-1
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+1
-1
test/src/unit-json_pointer.cpp
test/src/unit-json_pointer.cpp
+4
-0
No files found.
include/nlohmann/detail/json_pointer.hpp
View file @
7476f5ee
...
@@ -267,7 +267,7 @@ class json_pointer
...
@@ -267,7 +267,7 @@ class json_pointer
@since version 3.6.0
@since version 3.6.0
*/
*/
const
std
::
string
&
back
()
const
std
::
string
&
back
()
const
{
{
if
(
JSON_HEDLEY_UNLIKELY
(
empty
()))
if
(
JSON_HEDLEY_UNLIKELY
(
empty
()))
{
{
...
...
single_include/nlohmann/json.hpp
View file @
7476f5ee
...
@@ -10232,7 +10232,7 @@ class json_pointer
...
@@ -10232,7 +10232,7 @@ class json_pointer
@since version 3.6.0
@since version 3.6.0
*/
*/
const std::string& back()
const std::string& back()
const
{
{
if (JSON_HEDLEY_UNLIKELY(empty()))
if (JSON_HEDLEY_UNLIKELY(empty()))
{
{
...
...
test/src/unit-json_pointer.cpp
View file @
7476f5ee
...
@@ -559,6 +559,10 @@ TEST_CASE("JSON pointers")
...
@@ -559,6 +559,10 @@ TEST_CASE("JSON pointers")
CHECK
(
!
ptr
.
empty
());
CHECK
(
!
ptr
.
empty
());
CHECK
(
j
[
ptr
]
==
j
[
"answer"
][
"everything"
]);
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
();
ptr
.
pop_back
();
ptr
.
pop_back
();
CHECK
(
ptr
.
empty
());
CHECK
(
ptr
.
empty
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment