include/systools/win32/comtools.hxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
New commits: commit 44406d90e657afeea66e43b22eb4d4c897639276 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Mon Dec 20 19:13:46 2021 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Tue Dec 21 08:00:55 2021 +0100 Introduce move ctor/assignment for sal::systools::COMReference Change-Id: I063a1d4a42eb28e2b81956b9b2baefaad3208234 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127190 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/include/systools/win32/comtools.hxx b/include/systools/win32/comtools.hxx index d26f680569e5..3139cc94b305 100644 --- a/include/systools/win32/comtools.hxx +++ b/include/systools/win32/comtools.hxx @@ -69,6 +69,11 @@ namespace sal::systools { } + COMReference(COMReference<T>&& other) : + COMReference(std::exchange(other.com_ptr_, nullptr), false) + { + } + // Query from IUnknown*, using COM_QUERY or COM_QUERY_THROW tags template <typename T2, typename TAG> COMReference(const COMReference<T2>& p, TAG t) @@ -81,6 +86,16 @@ namespace sal::systools return operator=(other.com_ptr_); } + COMReference<T>& operator=(COMReference<T>&& other) + { + if (com_ptr_ != other.com_ptr_) + { + clear(); + std::swap(com_ptr_, other.com_ptr_); + } + return *this; + } + COMReference<T>& operator=(T* comptr) { assign(comptr);