diff options
author | Milo Yip <miloyip@gmail.com> | 2018-12-18 04:32:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-18 04:32:09 +0300 |
commit | b56eb28575626104922d77f6d74a116c5dbd611e (patch) | |
tree | b9df54d9d4138254a835554098161434fe0c7962 /include/rapidjson/pointer.h | |
parent | eb6ee17d2dcc596806875b2167cf8bf54f37e425 (diff) | |
parent | 8549e3db6a3cdecf4f8cdb9ee9f49d49e6320dc1 (diff) |
Merge branch 'master' into pointer_less_than
Diffstat (limited to 'include/rapidjson/pointer.h')
-rw-r--r-- | include/rapidjson/pointer.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/include/rapidjson/pointer.h b/include/rapidjson/pointer.h index 51805a63..063abab9 100644 --- a/include/rapidjson/pointer.h +++ b/include/rapidjson/pointer.h @@ -200,6 +200,36 @@ public: return *this; } + //! Swap the content of this pointer with an other. + /*! + \param other The pointer to swap with. + \note Constant complexity. + */ + GenericPointer& Swap(GenericPointer& other) RAPIDJSON_NOEXCEPT { + internal::Swap(allocator_, other.allocator_); + internal::Swap(ownAllocator_, other.ownAllocator_); + internal::Swap(nameBuffer_, other.nameBuffer_); + internal::Swap(tokens_, other.tokens_); + internal::Swap(tokenCount_, other.tokenCount_); + internal::Swap(parseErrorOffset_, other.parseErrorOffset_); + internal::Swap(parseErrorCode_, other.parseErrorCode_); + return *this; + } + + //! free-standing swap function helper + /*! + Helper function to enable support for common swap implementation pattern based on \c std::swap: + \code + void swap(MyClass& a, MyClass& b) { + using std::swap; + swap(a.pointer, b.pointer); + // ... + } + \endcode + \see Swap() + */ + friend inline void swap(GenericPointer& a, GenericPointer& b) RAPIDJSON_NOEXCEPT { a.Swap(b); } + //@} //!@name Append token |