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>
This commit is contained in:
@@ -101,6 +101,13 @@ public:
|
|||||||
: m_rInnerRef (handle.m_rInnerRef)
|
: 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.
|
/** Up-casting conversion constructor: Copies interface reference.
|
||||||
|
|
||||||
Does not work for up-casts to ambiguous bases. For the special case of
|
Does not work for up-casts to ambiguous bases. For the special case of
|
||||||
@@ -157,7 +164,7 @@ public:
|
|||||||
m_rInnerRef.set(pBody);
|
m_rInnerRef.set(pBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Up-casting assignment operator.
|
/** Up-casting copy assignment operator.
|
||||||
|
|
||||||
Does not work for up-casts to ambiguous bases.
|
Does not work for up-casts to ambiguous bases.
|
||||||
|
|
||||||
@@ -173,6 +180,22 @@ public:
|
|||||||
return *this;
|
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)
|
VclPtr & operator =(reference_type * pBody)
|
||||||
{
|
{
|
||||||
m_rInnerRef.set(pBody);
|
m_rInnerRef.set(pBody);
|
||||||
@@ -323,7 +346,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
Assignment that releases the last reference.
|
Assignment that releases the last reference.
|
||||||
*/
|
*/
|
||||||
inline ScopedVclPtr<reference_type>& operator= (reference_type * pBody)
|
inline ScopedVclPtr<reference_type>& operator = (reference_type * pBody)
|
||||||
{
|
{
|
||||||
disposeAndReset(pBody);
|
disposeAndReset(pBody);
|
||||||
return *this;
|
return *this;
|
||||||
@@ -361,7 +384,7 @@ private:
|
|||||||
// Most likely we don't want this default copy-construtor.
|
// Most likely we don't want this default copy-construtor.
|
||||||
ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete;
|
ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete;
|
||||||
// And certainly we don't want a default assignment operator.
|
// 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
|
// And disallow reset as that doesn't call disposeAndClear on the original reference
|
||||||
void reset() = delete;
|
void reset() = delete;
|
||||||
void reset(reference_type *pBody) = delete;
|
void reset(reference_type *pBody) = delete;
|
||||||
|
Reference in New Issue
Block a user