summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2016-11-10 12:05:09 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2016-11-11 06:54:46 +0000
commit071e23fee07b92b8f07800cda3ca7e66afe818ae (patch)
tree42e0e637a14ec6652a44124acd403c25d8210f7a
parentc64b8ffe851d3320a15071fa4bc4b0f12e9939d5 (diff)
add move operators for VclPtr
Change-Id: Ic32894d13aac2d8038afec2efebcc544f1c408af Reviewed-on: https://gerrit.libreoffice.org/30748 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--include/vcl/vclptr.hxx29
1 files changed, 26 insertions, 3 deletions
diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx
index b4ef55325cfe..f56e006d58e4 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;