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
adc73d6d
Commit
adc73d6d
authored
May 29, 2017
by
HenryLee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the arithmetic mistakes in reverse iterator
parent
ed62129f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
17 deletions
+17
-17
src/json.hpp
src/json.hpp
+3
-3
test/src/unit-iterators2.cpp
test/src/unit-iterators2.cpp
+14
-14
No files found.
src/json.hpp
View file @
adc73d6d
...
@@ -8672,7 +8672,7 @@ class basic_json
...
@@ -8672,7 +8672,7 @@ class basic_json
json_reverse_iterator
operator
+
(
difference_type
i
)
const
json_reverse_iterator
operator
+
(
difference_type
i
)
const
{
{
auto
result
=
*
this
;
auto
result
=
*
this
;
result
+
=
i
;
result
-
=
i
;
return
result
;
return
result
;
}
}
...
@@ -8680,14 +8680,14 @@ class basic_json
...
@@ -8680,14 +8680,14 @@ class basic_json
json_reverse_iterator
operator
-
(
difference_type
i
)
const
json_reverse_iterator
operator
-
(
difference_type
i
)
const
{
{
auto
result
=
*
this
;
auto
result
=
*
this
;
result
-
=
i
;
result
+
=
i
;
return
result
;
return
result
;
}
}
/// return difference
/// return difference
difference_type
operator
-
(
const
json_reverse_iterator
&
other
)
const
difference_type
operator
-
(
const
json_reverse_iterator
&
other
)
const
{
{
return
this
->
base
()
-
other
.
base
();
return
other
.
base
()
-
this
->
base
();
}
}
/// access to successor
/// access to successor
...
...
test/src/unit-iterators2.cpp
View file @
adc73d6d
...
@@ -747,7 +747,7 @@ TEST_CASE("iterators 2")
...
@@ -747,7 +747,7 @@ TEST_CASE("iterators 2")
it
+=
3
;
it
+=
3
;
CHECK
((
j_array
.
rbegin
()
+
3
)
==
it
);
CHECK
((
j_array
.
rbegin
()
+
3
)
==
it
);
CHECK
((
it
-
3
)
==
j_array
.
rbegin
());
CHECK
((
it
-
3
)
==
j_array
.
rbegin
());
CHECK
((
j_array
.
rbegin
()
-
it
)
==
3
);
CHECK
((
it
-
j_array
.
rbegin
()
)
==
3
);
CHECK
(
*
it
==
json
(
3
));
CHECK
(
*
it
==
json
(
3
));
it
-=
2
;
it
-=
2
;
CHECK
(
*
it
==
json
(
5
));
CHECK
(
*
it
==
json
(
5
));
...
@@ -757,7 +757,7 @@ TEST_CASE("iterators 2")
...
@@ -757,7 +757,7 @@ TEST_CASE("iterators 2")
it
+=
3
;
it
+=
3
;
CHECK
((
j_array
.
crbegin
()
+
3
)
==
it
);
CHECK
((
j_array
.
crbegin
()
+
3
)
==
it
);
CHECK
((
it
-
3
)
==
j_array
.
crbegin
());
CHECK
((
it
-
3
)
==
j_array
.
crbegin
());
CHECK
((
j_array
.
crbegin
()
-
it
)
==
3
);
CHECK
((
it
-
j_array
.
crbegin
()
)
==
3
);
CHECK
(
*
it
==
json
(
3
));
CHECK
(
*
it
==
json
(
3
));
it
-=
2
;
it
-=
2
;
CHECK
(
*
it
==
json
(
5
));
CHECK
(
*
it
==
json
(
5
));
...
@@ -769,9 +769,9 @@ TEST_CASE("iterators 2")
...
@@ -769,9 +769,9 @@ TEST_CASE("iterators 2")
{
{
auto
it
=
j_null
.
rbegin
();
auto
it
=
j_null
.
rbegin
();
it
+=
3
;
it
+=
3
;
CHECK
((
j_null
.
rbegin
()
+
3
)
==
it
);
CHECK
((
j_null
.
rbegin
()
-
3
)
==
it
);
CHECK
((
it
-
3
)
==
j_null
.
rbegin
());
CHECK
((
it
+
3
)
==
j_null
.
rbegin
());
CHECK
((
j_null
.
rbegin
()
-
it
)
==
3
);
CHECK
((
it
-
j_null
.
rbegin
()
)
==
3
);
CHECK
(
it
!=
j_null
.
rend
());
CHECK
(
it
!=
j_null
.
rend
());
it
-=
3
;
it
-=
3
;
CHECK
(
it
==
j_null
.
rend
());
CHECK
(
it
==
j_null
.
rend
());
...
@@ -779,9 +779,9 @@ TEST_CASE("iterators 2")
...
@@ -779,9 +779,9 @@ TEST_CASE("iterators 2")
{
{
auto
it
=
j_null
.
crbegin
();
auto
it
=
j_null
.
crbegin
();
it
+=
3
;
it
+=
3
;
CHECK
((
j_null
.
crbegin
()
+
3
)
==
it
);
CHECK
((
j_null
.
crbegin
()
-
3
)
==
it
);
CHECK
((
it
-
3
)
==
j_null
.
crbegin
());
CHECK
((
it
+
3
)
==
j_null
.
crbegin
());
CHECK
((
j_null
.
crbegin
()
-
it
)
==
3
);
CHECK
((
it
-
j_null
.
crbegin
()
)
==
3
);
CHECK
(
it
!=
j_null
.
crend
());
CHECK
(
it
!=
j_null
.
crend
());
it
-=
3
;
it
-=
3
;
CHECK
(
it
==
j_null
.
crend
());
CHECK
(
it
==
j_null
.
crend
());
...
@@ -793,9 +793,9 @@ TEST_CASE("iterators 2")
...
@@ -793,9 +793,9 @@ TEST_CASE("iterators 2")
{
{
auto
it
=
j_value
.
rbegin
();
auto
it
=
j_value
.
rbegin
();
it
+=
3
;
it
+=
3
;
CHECK
((
j_value
.
rbegin
()
+
3
)
==
it
);
CHECK
((
j_value
.
rbegin
()
-
3
)
==
it
);
CHECK
((
it
-
3
)
==
j_value
.
rbegin
());
CHECK
((
it
+
3
)
==
j_value
.
rbegin
());
CHECK
((
j_value
.
rbegin
()
-
it
)
==
3
);
CHECK
((
it
-
j_value
.
rbegin
()
)
==
3
);
CHECK
(
it
!=
j_value
.
rend
());
CHECK
(
it
!=
j_value
.
rend
());
it
-=
3
;
it
-=
3
;
CHECK
(
*
it
==
json
(
42
));
CHECK
(
*
it
==
json
(
42
));
...
@@ -803,9 +803,9 @@ TEST_CASE("iterators 2")
...
@@ -803,9 +803,9 @@ TEST_CASE("iterators 2")
{
{
auto
it
=
j_value
.
crbegin
();
auto
it
=
j_value
.
crbegin
();
it
+=
3
;
it
+=
3
;
CHECK
((
j_value
.
crbegin
()
+
3
)
==
it
);
CHECK
((
j_value
.
crbegin
()
-
3
)
==
it
);
CHECK
((
it
-
3
)
==
j_value
.
crbegin
());
CHECK
((
it
+
3
)
==
j_value
.
crbegin
());
CHECK
((
j_value
.
crbegin
()
-
it
)
==
3
);
CHECK
((
it
-
j_value
.
crbegin
()
)
==
3
);
CHECK
(
it
!=
j_value
.
crend
());
CHECK
(
it
!=
j_value
.
crend
());
it
-=
3
;
it
-=
3
;
CHECK
(
*
it
==
json
(
42
));
CHECK
(
*
it
==
json
(
42
));
...
...
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