diff options
author | Daniel Robertson <danlrobertson89@gmail.com> | 2015-11-03 09:47:36 -0500 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-11-06 15:19:29 +0000 |
commit | f15d11a9f8d6c783fd8c937256fa3372f8e4fe01 (patch) | |
tree | ae3cd96514c43899b17b32f1f7ba62bc254ef665 /include/rtl | |
parent | unused warning in DISABLE_DYNLOADING fixed (diff) | |
download | core-f15d11a9f8d6c783fd8c937256fa3372f8e4fe01.tar.gz core-f15d11a9f8d6c783fd8c937256fa3372f8e4fe01.zip |
rtl::Reference Add move construction/assignment
Add move constructor and appropriately overloaded assignment operator to
rtl::Reference, and add basic unit tests for the reference counting of
rtl::Reference.
Change-Id: Ia7ff5d786bdf3b17709cec06608c91e22379746c
Reviewed-on: https://gerrit.libreoffice.org/19762
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/rtl')
-rw-r--r-- | include/rtl/ref.hxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/rtl/ref.hxx b/include/rtl/ref.hxx index 097584b1a276..82dda83eba75 100644 --- a/include/rtl/ref.hxx +++ b/include/rtl/ref.hxx @@ -72,6 +72,15 @@ public: m_pBody->acquire(); } +#ifdef LIBO_INTERNAL_ONLY + /** Move constructor... + */ + inline Reference (Reference<reference_type> && handle) + : m_pBody (handle.m_pBody) + { + handle.m_pBody = nullptr; + } +#endif /** Destructor... */ @@ -106,6 +115,24 @@ public: return set( handle.m_pBody ); } +#ifdef LIBO_INTERNAL_ONLY + /** Assignment. + * Unbinds this instance from its body (if bound), + * bind it to the body represented by the handle, and + * set the body represented by the handle to nullptr. + */ + inline Reference<reference_type> & + SAL_CALL operator= (Reference<reference_type> && handle) + { + // self-movement guts ourself + if (m_pBody) + m_pBody->release(); + m_pBody = handle.m_pBody; + handle.m_pBody = nullptr; + return *this; + } +#endif + /** Assignment... */ inline Reference<reference_type> & |