Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
055f1fa6
Commit
055f1fa6
authored
Dec 10, 2018
by
ylavic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add less than operator to Pointer.
Allows to sort pointers in (std-)containers and/or index by them.
parent
66eb6067
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
pointer.h
include/rapidjson/pointer.h
+33
-0
No files found.
include/rapidjson/pointer.h
View file @
055f1fa6
...
...
@@ -356,6 +356,39 @@ public:
*/
bool
operator
!=
(
const
GenericPointer
&
rhs
)
const
{
return
!
(
*
this
==
rhs
);
}
//! Less than operator.
/*!
\note Invalid pointers are never lesser than valid ones.
*/
bool
operator
<
(
const
GenericPointer
&
rhs
)
const
{
if
(
!
IsValid
())
return
false
;
if
(
!
rhs
.
IsValid
())
return
true
;
size_t
i
=
0
,
lCount
=
tokenCount_
,
rCount
=
rhs
.
tokenCount_
;
for
(;;)
{
if
(
!
rCount
)
return
false
;
if
(
!
lCount
)
return
true
;
if
(
tokens_
[
i
].
index
!=
rhs
.
tokens_
[
i
].
index
)
return
tokens_
[
i
].
index
<
rhs
.
tokens_
[
i
].
index
;
if
(
tokens_
[
i
].
length
>
rhs
.
tokens_
[
i
].
length
)
return
std
::
memcmp
(
tokens_
[
i
].
name
,
rhs
.
tokens_
[
i
].
name
,
sizeof
(
Ch
)
*
rhs
.
tokens_
[
i
].
length
)
<
0
;
int
cmp
=
std
::
memcmp
(
tokens_
[
i
].
name
,
rhs
.
tokens_
[
i
].
name
,
sizeof
(
Ch
)
*
tokens_
[
i
].
length
);
if
(
cmp
||
tokens_
[
i
].
length
!=
rhs
.
tokens_
[
i
].
length
)
return
cmp
<=
0
;
lCount
--
;
rCount
--
;
i
++
;
}
}
//@}
//!@name Stringify
...
...
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