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
9ab2621e
Commit
9ab2621e
authored
Jul 31, 2014
by
miloyip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Erase(ConstValueIterator) and Erase(ConstValueIterator,ConstValueIterator)
As std::vector::erase() overloads added in C++11
parent
71c84025
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
document.h
include/rapidjson/document.h
+8
-0
valuetest.cpp
test/unittest/valuetest.cpp
+5
-5
No files found.
include/rapidjson/document.h
View file @
9ab2621e
...
...
@@ -1008,6 +1008,10 @@ int z = a[0u].GetInt(); // This works too.
return
Erase
(
pos
,
pos
+
1
);
}
ValueIterator
Erase
(
ConstValueIterator
pos
)
{
return
Erase
(
const_cast
<
ValueIterator
>
(
pos
));
}
//! Remove elements in the range [first, last) of the array.
/*!
\param pos iterator to the element to remove
...
...
@@ -1029,6 +1033,10 @@ int z = a[0u].GetInt(); // This works too.
return
first
;
}
ValueIterator
Erase
(
ConstValueIterator
first
,
ConstValueIterator
last
)
{
return
Erase
(
const_cast
<
ValueIterator
>
(
first
),
const_cast
<
ValueIterator
>
(
last
));
}
//@}
//!@name Number
...
...
test/unittest/valuetest.cpp
View file @
9ab2621e
...
...
@@ -628,11 +628,11 @@ TEST(Value, Array) {
x
.
PushBack
(
Value
(
kArrayType
).
PushBack
(
i
,
allocator
).
Move
(),
allocator
);
// Erase the first
itr
=
x
.
Erase
(
x
.
Begin
());
EXPECT_EQ
(
x
.
Begin
(),
itr
);
EXPECT_EQ
(
9u
,
x
.
Size
());
itr
=
x
.
Erase
(
y
.
Begin
());
// const iteator is also OK
EXPECT_EQ
(
y
.
Begin
(),
itr
);
EXPECT_EQ
(
9u
,
y
.
Size
());
for
(
int
i
=
0
;
i
<
9
;
i
++
)
EXPECT_EQ
(
i
+
1
,
x
[
i
][
0u
].
GetInt
());
EXPECT_EQ
(
i
+
1
,
y
[
i
][
0u
].
GetInt
());
// Ease the last
itr
=
x
.
Erase
(
x
.
End
()
-
1
);
...
...
@@ -659,7 +659,7 @@ TEST(Value, Array) {
for
(
unsigned
i
=
0
;
i
<
n
;
i
++
)
x
.
PushBack
(
Value
(
kArrayType
).
PushBack
(
i
,
allocator
).
Move
(),
allocator
);
itr
=
x
.
Erase
(
x
.
Begin
()
+
first
,
x
.
Begin
()
+
last
);
itr
=
x
.
Erase
(
y
.
Begin
()
+
first
,
y
.
Begin
()
+
last
);
// const iterator is also OK
if
(
last
==
n
)
EXPECT_EQ
(
x
.
End
(),
itr
);
else
...
...
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