diff options
author | ylavic <ylavic.dev@gmail.com> | 2018-12-17 16:33:32 +0300 |
---|---|---|
committer | ylavic <ylavic.dev@gmail.com> | 2018-12-17 16:33:32 +0300 |
commit | a66cf7924cce69be801a25bf803cef16f1a75693 (patch) | |
tree | b9cc8317fd0b582555d0dcaa3424ce3729316987 /include/rapidjson/pointer.h | |
parent | 66eb6067b10fd02e419f88816a8833a64eb33551 (diff) |
Allow to (std::)Swap two pointers.
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 3d339f24..2ea0cdd5 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 |