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
46e16963
Commit
46e16963
authored
Jul 13, 2015
by
Philipp A. Hartmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add free inline `swap` functions
parent
0ebe16e1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
document.h
include/rapidjson/document.h
+4
-0
documenttest.cpp
test/unittest/documenttest.cpp
+12
-0
valuetest.cpp
test/unittest/valuetest.cpp
+6
-0
No files found.
include/rapidjson/document.h
View file @
46e16963
...
...
@@ -660,6 +660,8 @@ public:
return
*
this
;
}
friend
inline
void
swap
(
GenericValue
&
a
,
GenericValue
&
b
)
RAPIDJSON_NOEXCEPT
{
a
.
Swap
(
b
);
}
//! Prepare Value for move semantics
/*! \return *this */
GenericValue
&
Move
()
RAPIDJSON_NOEXCEPT
{
return
*
this
;
}
...
...
@@ -1818,6 +1820,8 @@ public:
return
*
this
;
}
friend
inline
void
swap
(
GenericDocument
&
a
,
GenericDocument
&
b
)
RAPIDJSON_NOEXCEPT
{
a
.
Swap
(
b
);
}
//!@name Parse from stream
//!@{
...
...
test/unittest/documenttest.cpp
View file @
46e16963
...
...
@@ -19,6 +19,7 @@
#include "rapidjson/encodedstream.h"
#include "rapidjson/stringbuffer.h"
#include <sstream>
#include <algorithm>
using
namespace
rapidjson
;
...
...
@@ -223,6 +224,17 @@ TEST(Document, Swap) {
Document
().
Swap
(
d2
);
EXPECT_TRUE
(
d2
.
IsNull
());
EXPECT_NE
(
&
d2
.
GetAllocator
(),
&
a
);
// testing std::swap compatibility
d1
.
SetBool
(
true
);
using
std
::
swap
;
swap
(
d1
,
d2
);
EXPECT_TRUE
(
d1
.
IsNull
());
EXPECT_TRUE
(
d2
.
IsTrue
());
swap
(
o
,
d2
);
EXPECT_TRUE
(
o
.
IsTrue
());
EXPECT_TRUE
(
d2
.
IsArray
());
}
...
...
test/unittest/valuetest.cpp
View file @
46e16963
...
...
@@ -272,6 +272,12 @@ TEST(Value, Swap) {
EXPECT_TRUE
(
v1
.
IsObject
());
EXPECT_TRUE
(
v2
.
IsInt
());
EXPECT_EQ
(
1234
,
v2
.
GetInt
());
// testing std::swap compatibility
using
std
::
swap
;
swap
(
v1
,
v2
);
EXPECT_TRUE
(
v1
.
IsInt
());
EXPECT_TRUE
(
v2
.
IsObject
());
}
TEST
(
Value
,
Null
)
{
...
...
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