[Libreoffice-commits] core.git: include/vcl

Noel Grandin noel.grandin at collabora.co.uk
Fri Nov 11 06:55:10 UTC 2016


 include/vcl/vclptr.hxx |   29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

New commits:
commit 071e23fee07b92b8f07800cda3ca7e66afe818ae
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Nov 10 12:05:09 2016 +0200

    add move operators for VclPtr
    
    Change-Id: Ic32894d13aac2d8038afec2efebcc544f1c408af
    Reviewed-on: https://gerrit.libreoffice.org/30748
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx
index b4ef553..f56e006 100644
--- a/include/vcl/vclptr.hxx
+++ b/include/vcl/vclptr.hxx
@@ -101,6 +101,13 @@ public:
         : m_rInnerRef (handle.m_rInnerRef)
     {}
 
+    /** Move constructor...
+     */
+    inline VclPtr (VclPtr<reference_type> && handle)
+        : m_rInnerRef ( std::move(handle.m_rInnerRef) )
+    {
+    }
+
     /** Up-casting conversion constructor: Copies interface reference.
 
         Does not work for up-casts to ambiguous bases.  For the special case of
@@ -157,7 +164,7 @@ public:
         m_rInnerRef.set(pBody);
     }
 
-    /** Up-casting assignment operator.
+    /** Up-casting copy assignment operator.
 
         Does not work for up-casts to ambiguous bases.
 
@@ -173,6 +180,22 @@ public:
         return *this;
     }
 
+    /** move assignment operator.
+    */
+    VclPtr & operator =(VclPtr<reference_type> && rRef)
+    {
+        m_rInnerRef = std::move(rRef);
+        return *this;
+    }
+
+    /** copy assignment operator.
+    */
+    VclPtr & operator =(const VclPtr<reference_type> & rRef)
+    {
+        m_rInnerRef = rRef;
+        return *this;
+    }
+
     VclPtr & operator =(reference_type * pBody)
     {
         m_rInnerRef.set(pBody);
@@ -323,7 +346,7 @@ public:
     /**
        Assignment that releases the last reference.
      */
-    inline ScopedVclPtr<reference_type>& operator= (reference_type * pBody)
+    inline ScopedVclPtr<reference_type>& operator = (reference_type * pBody)
     {
         disposeAndReset(pBody);
         return *this;
@@ -361,7 +384,7 @@ private:
     // Most likely we don't want this default copy-construtor.
     ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete;
     // And certainly we don't want a default assignment operator.
-    ScopedVclPtr<reference_type>& operator= (const ScopedVclPtr<reference_type> &) = delete;
+    ScopedVclPtr<reference_type>& operator = (const ScopedVclPtr<reference_type> &) = delete;
     // And disallow reset as that doesn't call disposeAndClear on the original reference
     void reset() = delete;
     void reset(reference_type *pBody) = delete;


More information about the Libreoffice-commits mailing list